Compair two strings different but similar

Hello everyone, I need to compare 2 strings where

strVar1=“PRI, SL6, SN3, V0D”

strVar2=“IRP, 3SN, SL6, V0D”

the result between the 2 is equal or true

because if you observe in detail all the characters of strvar1 contain in strvar2 removing the commas

Hi @Israel_Silva ,

Could you check with the below Expression :

Here, Assuming that the input is a String data.

Regex.Replace(strVar1,"\s|,","").OrderBy(Function(x)x).SequenceEqual(Regex.Replace(strVar2,"\s|,","").OrderBy(Function(x)x))

Let us know if this doesn’t work.

1 Like

Hi @Israel_Silva ,

Assuming that we can split it on the basis of a delimiter(which in this case is comma), this ought to do the trick:

str_1.Split(","c,StringSplitOptions.RemoveEmptyEntries).All(Function(a) str_1.Split(","c,StringSplitOptions.RemoveEmptyEntries).Contains(a))

CompareTwoSTrings.xaml (5.8 KB)
P.S. Interesting challenge btw :slightly_smiling_face:

Kind Regards,
Ashwin A.K

1 Like

You hit the nail on the head! TKS :blue_heart:

1 Like

YOUR SOLUTION WORKED HERE TOO!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.