Regex Bulder

Hi Community, I have dynamic o/p responses.
1st Input
BEN Andrew Grove 100
BEN Suzy 50
INS Marshall

2nd Input
BEN Alex 100
PAY Marshall

and so on… from those o/p I want only Name and Percentage associate with “BEN”

o/p
1st
Andrew Grove 100
Suzy 50

2nd
Alex 100

can anyone help with regex?

1st Input

Input= "BEN Andrew Grove 100
BEN Suzy 50
INS Marshall"
Output= System.Text.RegularExpressions.Regex.Matches(Input,"(?<=BEN\s*).*")

Output is of DataType Ienumerable(System.Text.RegularExpression.Match)
Use For Each loop to Iterate through Output and print currentitem.

2nd Input

Input="BEN Alex 100
PAY Marshall"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=BEN\s*).*").Value

Regards

Hi @ch460960

You can use the first regex provided for both the inputs and make sure to use the for each because the the first input contains Ben for multiple times and you need to print all those and in the same manner the second input contains Ben for only one time so if you use for each the second input will be iterated only for one time.so it’s better to use both inputs with the first provided regex.

Regards

Hi @ch460960

Input= "BEN Andrew Grove 100
BEN Suzy 50
INS Marshall
BEN Alex 100
PAY Marshall"
Output= System.Text.RegularExpressions.Regex.Matches(Input,"(?<=BEN\s*).*")

Output is of DataType IEnumerable(System.Text.RegularExpressions.Match)

→ Use For Each loop to iterate through Output and print currentItem.
Workflow:


xaml:
Sequence13.xaml (8.7 KB)
Output:
image

Regards

@vrdabberu , Thank you so much :slight_smile:

1 Like

You’re welcome @ch460960

Happy Automation

Regards

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