Split string using UiPath

“ACN - Test1 & Test2 15.09.23”
I want to get Test1 , Test2 from this string. Can someone help to do this ?

Sequence.xaml (6.3 KB)

hope this clarifies
Usha

1 Like

Starting with a simple Pattern
grafik

grafik

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

Hi @ajnaraya
If the - and date will be constantly be there you can use like this

System.Text.RegularExpresssions.Regex.Match(InputString,"(?s)(?<=\-)(.*?)(?=\d{2})").ToString.Trim

image

This will give you like Test1 & Test2

If you want them in a single string variable you replace the &

System.Text.RegularExpresssions.Regex.Match(InputString,"(?s)(?<=\-)(.*?)(?=\d{2})").ToString.Trim.Replace("&","")

If you want liek a array you split using &

System.Text.RegularExpresssions.Regex.Match(InputString,"(?s)(?<=\-)(.*?)(?=\d{2})").ToString.Trim.Split("&"c)

Hope this Helps!!

Regards
Sudharsan

Hi @ajnaraya

Assign: originalString = "ACN - Test1 & Test2 15.09.23"
Assign: stringArray = originalString.Split({" ", "&"c}, StringSplitOptions.RemoveEmptyEntries)
Assign: Test1 = stringArray(2)
Assign: Test2 = stringArray(4)

Hope it helps!!

1 Like

@ajnaraya

System.Text.RegularExpressions.Regex.Matches(str,“\bTest[0-9]\b”).ToArray

image

1 Like

Hi, you can use below expression:

System.Text.RegularExpressions.Regex.Matches(“ACN - Test1 & Test2 15.09.23”, “Test\d+”)

Hi @ajnaraya

Try this

(?<=\-\s+).*(?=\s+\&\s+)|(?<=\&\s+).*(?=\s+)

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