For each row - read only last 5 numeric characters

I am working with For each row in Studio to read ID numbers from a CSV file. I wish to configure my robot further to only read the last 5 numeric characters from the right-hand side of the number in my data table “input”. The last character is an alphanumeric character in all cases.

Hey @andrew.haworth,

Use the below method



Thanks this is now working well!

Great To hear that it’s working fine for you.

Could you please mark it as a solution so that thread should get closed and helpful for others as well.

Thanks Sanjit, I have updated the solution check flag. Can I ask if I wished to read the last 5 characters and ignore the alphanumeric character at the very end of the number. What is the syntax?

Are you looking for this?

Thanks Peter,

Can you explain to me how I append this to my existing (working code)


at the moment this reads the last 5 characters. I wish to ignore the last character only

we use a regex.match as the following:


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

Hey Peter,

When I add that Test to my UI Path activity I obtain the following error:

Option Strict On disallows implicit conversions from ‘Object’ to ‘String’

Can you advise?


check your involved datatypes

feel free to share a snap and more details with us

so my data item would be in the format “XXXXXXXY”

where X= numeric
and Y = alphanumeric

it is the “Y” I wish to remove ignore

What if I just counted from the left?


Here is my activity. The PID should be read into my data table without the alphanumeric character at the end. This character is randomly generated.

My problem is to find the right syntax to read only 7 characters in combination with a For each row in a data table activity

Best regards



its about patterns


Sorry do I just write the Regex command in the Messagebox?


was demonstrated above

so will use it there, where you need/want to work with value.

I am really sorry Peter but I am just not getting this! I am quite new to RPA and would really like to make this work for my workflow:

Each time I try to utilise the System.text.Regular Expressions command I obtain a validation error.
Would you have time If I was to share my test project with you?


no problem, but ensure that the relevant things are also shared with us (e.g. implementations, validation messages in complete)

row(“PID”) will return a reult of datatype: Object, but a string is needed for the regex input

As usually use row(“PID”).toString for the Regex input

Ok thanks Peter, I have attached the project folder. The robot will read a sample file located in the samples directory in the project folder. I also include a screenshot with my requirements (in case 'i was not good at explaining previously?!)
Really appreciate the support!

For Each (4.2 KB)

Many thanks



I read your last message again and here you go! It works!