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

row("name").ToString.Substring(row("name").ToString.Length-3)

Thanks,
Sanjit

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?
grafik

Thanks Peter,

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

row(“IDnumber”).ToString.Substring(row(“IDnumber”).ToString.Length-5)

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:
grafik

System.text.RegularExpressions.Regex.Match(yourStringVar,"(\d{5})(?=\D*?$)").Value

[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?

A

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?

A

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

A

grafik

its about patterns

grafik
(\d{5,})(?=\D*?$)

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

ie

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?

Andrew

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 Row.zip (4.2 KB)

Many thanks

A

Peter,

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

Thanks

A