Solved

check each letter and remove

Posted on 2011-03-23
6
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

751 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