How can i compare two strings with maximum words ? compare activity is not working

Example. var1 = “Abnormal uterine and veginal bleeding, unspecified”
var2= “Abnormal Uterine Bleeding”
i have used va1.compare(var1) but as var1 consist of comma as well as and word it is not matching , Please help how can i match this two variable. My answer for this two variable should get matched because this two var are very much similar.

Hi @rishikesh_gaikwad

Have you tried with If condition

var1 = “Abnormal uterine and veginal bleeding, unspecified”

var2= “Abnormal Uterine Bleeding”

var1.contains(var2)

Regards
Gokul

Hi @rishikesh_gaikwad ,I hope you are doing well.
Try this:
var1.toLower.contains(var2.toLower)

The above expression will work successfully even during case mismatch.

Thanks & Regards,
Shubham Dutta

As mentioned we do see the case differences Uterine / uterine

Maybe you can respecify the match expectation: should it be checked if all words are found lik
Abnormal, yes | Uterine,yes |Bleeding, yes

Or the maximum part string
Abnormal Uterine

or a Wildcard logic:
Abnormal*Uterine*Bleeding

1 Like

If I understood correctly you want to check if all words of var2 exist in var1.

You can use the expression in the below. You can also use regex to remove punctuations.

isMatchStrings(boolean)=var2.Replace(“,”,“”).Split(" “c).ToArray().All(Function(x) var1.ToLower.Replace(”,“,”").Contains(x.ToLower))

Hi @rishikesh_gaikwad,

You could try to use Levenshtein Distance Algorithm to make the comparison. The algorithm considers two string inputs and return to you a percentage of how close the two strings are.

I don’t remember seeing this in any native package of studio, but u can find in the marketplace.

Hope it helps. :slightly_smiling_face:

image