Match the string and check if all the matches(Output of the macthes activity) are equal

Hi,

I want to use regex to match the account number. Once account number is retrieved I have to check if all the retrieved account numbers are same. Can you please help me to get the proper approach/solution.

String: “(Main customer Acct. 8478378332)” [Need to extract only the account number]

The same kind of text may present multiple times in my paragraph with different account numbers. So I want to put a condition to check if all the matched account numbers are equal?
Please help.

Use regex pattern as : \d{10}

You will get array of all matches the you can compare them.
To check if duplicates are there or not just write below condition

arr.count=arr.Distinct.count
If true means all are unique.
where arr is array of matches

Thanks,
Prathamesh

1 Like

Hi @Harsha_Vemula ,

Based on the Input format of the Text, we should able to use the Following Regex Pattern in Matches Activity :

(?<=Main customer Acct.\s*)\d*

Next, From the Matches Activity Output, we should be able to Determine if all the Account Number Extracted are the same.
Let’s consider resultMatches variable is the Output of the Matches

Then in an If Activity we should be able to use the Below Expression :

resultMatches.Cast(Of Match).Select(Function(x)x.value.ToString.Trim).Distinct.ToArray.Count=1

If the above Expression is True then it means all account numbers are the same.

1 Like

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