In a list of string identify those with 3 out of 4 characters similar to each other

Hello guys, we have a list of string. Now the task is to identify similar or same strings.

Example:
We can accept
123K - 133P

But we cant accept
456Z - 456H

SO at least 2 characters need to be different. at least
Looking forward to your help
Best Regards,
H.Noka

Heyy @hurmet.noka ,

You can use List(index).StartsWith(“Can”)
Replace index with number
or

You can put a for each loop and iterate
Put an If activity and there u put as currentItem.Startswith(“can”)

Hope it helps you

Use a “Regex Is Match” activity to validate the input string against the pattern for allowed strings. The pattern should allow any letter (A-Z) and any digit (0-9), and should only match when at least two characters are different. The pattern will look like this:
^(?=\D*\d)(?=\d*\D)[A-Z\d]{2,}$

Regards,

1 Like

maybe this Quick dirty approach can help:
uncommon
grafik
common
grafik

1 Like

Thank you for your answer.
I think you misunderstood my request, there is nothing to do with can or cant.

123K, 133P, 456Z, 456H strings are of this format.

Thank you

Peter you are the savoir :sparkles:

This is great, may I ask you please, how can I loop through the same datatable twice, but for each initial row, I check all the remaining rows not the whole datatable from the first row.

Just open a new topic for the new question as it is better to scope 1Topic = 1 case for an easier finding of solutions.

Please share also some sample data with us there as some parts from the question are not complete clear. Thanks

1 Like

Posted.
Thank you Peter

How in the world these two string have count 1 as distinct?

its counting the distincts

Yeah but this doesnt deliver the expected result. I want to check similarity of strings.
444F is clearly different from 740G

No problem, with the revised requirements we can adapt.

  • is the position relevant or only the count of same characters?

The position is relevant, basically strings that looks similar to human eye.
547G is different from 745G
This adds another layer of complexation I guess

Have a look here:

grafik

str1Var.Select(Function (x,i) Convert.ToInt32(x.toString.Equals(str2Var(i)))).Sum()

And also can turn the count
grafik

1 Like

image
You are a living legend. Thank you so much! :star_struck:

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