How to get a particular group of strings in a set of strings?

Good Day.

I am trying to get the a particular group of strings in a set of strings? For example, I want to get the phrase “a great day” only in this sentence:

May I know the solution for the said inquiry? Kindly see attached file for the .xaml file. Thank you.

String.xaml (5.6 KB)

Best regards,
Robert

Hi @RobertRussell_Monsalud

You can use this RegEx expression to achieve the result:

\b(?:a )?great day\b

UiPath Syntax:

resultString = System.Text.RegularExpressions.Regex.Match(yourInputString,"\b(?:a )?great day\b").ToString

Hope this helps,
Best Reards.

1 Like

@RobertRussell_Monsalud

In the XAML you shared looks like you’re using to as one of the delimiters. You can use is as the start of the marker and with RegEx you can do:

strExtracted = System.Text.RegularExpressions.Regex.Match(strExtracted, "(?<=is).+(?=to)").ToString.Trim

See XAML for more details

AGreatDay.xaml (5,7 KB)

image

Hope this helps!

1 Like

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