Matching a number within a string of random numbers

Hi

I need to compare a random string with another string, and identify the number of correct characters. e.g. random string = 4567, 2nd string = 1578. Need to show that 5 is correct and 7 is also correct. May I know how to do this?

Hi…

Please check the workflow… I hope it matches your requirement… :slightly_smiling_face:

Random.xaml (9.8 KB)

Maybe intersect from LINQ could be helpful achieving what you want?

Assign strMatches = "4567".Intersect("1578").ToArray

Cheers

1 Like

Hi Nimin

Thank you! Slightly different but yours is interesting!

Hi @Florent_Salendres

I don’t really understand, so sorry…

Using another, how about if I wanted to find out the number of times “6” appears in “1668”?

Appreciate your help!

Hiii,

You can use regex for this.
Assign int_variable= regex.Matches(“1668”,“6”).Count

Warm regards,
Nimin

Hi @donutlearns,

That’s alright, i was showing a more programatic approach which could have been interesting if you were not looking to handle multiple occurences on second string

The expression after the equal would be meant to be put onto the right part of an “assign” activity, to assign the new value to a new string.

Cheers