Avatar of PeterBaileyUk
PeterBaileyUk
 asked on

vb.net function

I would like to create a function that can compare two strings but not a normal compare:

Str1 "one two three"
Str2 "two one three"


it would check that the words in the string are identical (not case sensitive) but just in the wrong order. in the example here the output could be true

It needs to be efficient, maybe regex can do this or maybe vb.net has something a method for this.

I am in visual studio app
Visual Basic.NET

Avatar of undefined
Last Comment
PeterBaileyUk

8/22/2022 - Mon
Guy Hengel [angelIII / a3]

would this google project be what you are looking for?
https://code.google.com/p/google-diff-match-patch/
Ramkisan Jagtap

Better way could be create a string array and the compare the different values.
PeterBaileyUk

ASKER
i dont want too resolve close matches which may happen with fuzzy stuff. only where the words are all the same but in a different order
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
PeterBaileyUk

ASKER
I found this on a thread but not sure if this will work as text and the logic is the wrong intersect

Function RevIntersect(arr1() As String, arr2() As String) As String()
    Dim sResult, aux As New List(Of String)()

    aux.AddRange(arr1)
    aux.AddRange(arr2)

    For Each elem As String In aux
        If (Not arr1.Contains(elem) OrElse Not Arr2.Contains(elem)) AndAlso _
        Not sResult.Contains(elem) Then  
            sResult.Add(elem)
        End If
    Next

    Return sResult.ToArray()
End Function

Open in new window

Pallavi Godse

The .NET Framework provides several methods to compare the values of strings. So, it would be better to refer the link below -
https://msdn.microsoft.com/en-us/library/fbh501kz(v=vs.110).aspx
ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
PeterBaileyUk

ASKER
I am going to play around with this. one thing i used to do in access was use the immediate window and push values into a module function. Does VS offer up a similar thing.? Oh and thank you, ive been slow to respond today.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.