Split the text

I need to get the last number in each line.Text is extracted from PDf

Name batch order number amount page

Hiyu-4566 a3456 1 1 1,6789 1

Hiyu-5664 a3456 1 1 1,6789 7

Hiyu-5262 a3456 1 1 1,6789 8

Hiyu-6362 a3456 1 1 1,6789 15

Hiyu-6373 a3456 1 1 1,6789 23your tran started

So now from the above will be in string fromat I need to take the page number 1,7,8,15 until your trans started…This all will be in text format

Regex can help:

\b\d+(?=$|your tran started|\z)

How to use regix in UiPath

we added the CheatSheet for this

e.g. Single Match

strValue = System.Text.RegularExpressions.Regex.Match(YourStringVar, YourPatternString).Value



Hi @Demo_User

How about this Regular Expression

System.Text.RegularExpressions.Regex.Match(YourString,"\b\d+$|\d+(?=your tran started)").Tostring



1 Like

Hello @Demo_User ,
Try this

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\s)\d+$|(?<=\s)\d+(?=your tran)").Tostring.Trim

1 Like

When I use this am getting only the last digit …I want other page number as well

I want 1,7,8,15,23 as output not only 23

Try this

string.join(",",System.Text.RegularExpressions.Regex.Matches(YourString,"(?<=\s)\d+$|(?<=\s)\d+(?=your tran)"))

for all matches, we would use Regex.Matches method and then grabbing all values

  • by looping over the return result


  • using a LINQ for grabbing all values

Still returns single value

Try this

string.join(",",System.Text.RegularExpressions.Regex.Matches(YourString,"(?<=\s)\d+$|(?<=\s)\d+(?=\n|your tran)"))


Hi @Demo_User,

Try the following expression in UiPath assign activity with a variable of MatchCollection type.
System.Text.RegularExpressions.Regex.Matches(YoutText,“\d+(?=\n|your tran started)”)


Could please keep the string in text file and pass it as string then test it…It is not working for me

For me am getting the output 23, below i have document page number 1 of 14
Am getting 23,14 as output not the pervious values

About attached is the input file
Am getting 23,14 as output

Above is the input I have passed
Getting output 23,14
I need 8,15,23 as output

@Demo_User , If possible share the test document here,

Sorry its inside the another machine I cant able to share it

Try This

string.join(",",System.Text.RegularExpressions.Regex.Matches(YourString,"\b\d+(?=Your trans|\s\n)"))