Need help with string manipulation

Let’s say if I am using a screen scraping tool to extract a string from an app. I then stored the string to a variable called Code.

The first string looks like this:
Test 1 / 1 19286849 / 08.01.2020 525902 3100292135 VD01

The second string looks like this:
Code 6300181427 Region VD01 / PBSM22

Is there a way to manipulate the string so that I will only get 3100292135 (from that first string) and 6300181427 (from that second string)? They are always 10 digits.

I need one universal method to handle both cases.

Thanks so much!

Hi,

If there isn’t any other 10 or more digits number except your target number, the following expression will work.

System.Text.RegularExpressions.Regex.Match(strData,"\d{10}").Value

Regards,

1 Like

string1 =“Test 1 / 1 19286849 / 08.01.2020 525902 3100292135 VD01”

Use Assign activity and the below regex to get the 10 digits and store it in another variable

substring=System.Text.RegularExpressions.Regex.Match(string1.ToString,“\d{10}”).ToString.Trim

image

Thank you so much. It works as expected.

1 Like

Hi @skyblue1854

I think the following regex is better for your case.
”\b\d{10}\b”

Thanks! Do you mind explaining why? I am new to Regex.

The ”\b” means boundary, it will be better to match a string which is parted by space.

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