Solved

check each letter and remove

Posted on 2011-03-23
6
236 Views
Last Modified: 2012-05-11
str1: "CLIO EXTREME TOM TOM (75)"
str2: "CLIO EXTREME TOMTOM (75)"

I would like to traverse each character in str1 if i find it in str2 remove that character from str2

if what remains is a space then that remains the only difference in the strings so flag it as false

this will allow me to ignore strings that have done this TOM TOM vs TOMTOM and by doing this character by character it doesnt matter if they rearranged the words.

I am working in vba

0
Comment
Question by:PeterBaileyUk
  • 4
6 Comments
 
LVL 17

Expert Comment

by:JezWalters
ID: 35196951
Wouldn't removing all spaces from both strings, and then comparing the strings give you the same result?
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 35196960
Have you looked into Soundex algorithms (i.e. "fuzzy matches") for these operations? Soundex algorithms can determine if one set of characters very closely mimics another, which is (basically) what you're trying to do.

http://allenbrowne.com/vba-Soundex.html
0
 

Author Comment

by:PeterBaileyUk
ID: 35196964
botj interesting yes to Jez and i will look at the fuzzy logic
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 17

Assisted Solution

by:JezWalters
JezWalters earned 250 total points
ID: 35197003
You can remove spaces like this:
Option Explicit        ' Force explicit variable declaration
Option Compare Binary  ' Perform case-sensitive comparisons

Public Function RemoveSpace(pvarStrOption Explicit        ' Force explicit variable declaration
Option Compare Binary  ' Perform case-sensitive comparisons

Public Function RemoveSpace(pvarString As Variant) As String

    ' Declare variables
    Dim lngCharacter As Long

    ' Process string
    RemoveSpace = Nz(pvarString)  ' Cope with Null
    For lngCharacter = 1 To Len(RemoveSpace)
        If Mid(RemoveSpace, lngCharacter, 1) = " " Then
            RemoveSpace = Left(RemoveSpace, lngCharacter - 1) & Mid(RemoveSpace, lngCharacter + 1)
        End If
    Next

End Function

Open in new window

0
 
LVL 17

Expert Comment

by:JezWalters
ID: 35197012
Once you've created this function, you can use it in a query like this:

SELECT *, RemoveSpace(YourField1) <> RemoveSpace(YourField2) As Different
FROM YourTable
0
 
LVL 17

Expert Comment

by:JezWalters
ID: 35197052
How do you want to handle different capitalisation between the two strings?
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question