Unable to get matches to extract values using regex

I want to extract data from excel file data is: the combination of numbers 21963306493155800
11959762242152400 starting of the number will be 11 or 21. number length is 17 digits and the count of digits is fixed

I have try with regex pattern ^(11|21)[0-9]{15} and [1-2]{1}[1]{1}[0-9]{15}
in the regexr.com from the ^(11|21)[0-9]{15} pattern data are highlighted when i same regex pattern using in uipath match actvity data are not get highlighted

kindly help to resolve issues


1 Like

I hope it was just the ^ at the start…UiPAth regex syntax and regexr can differ.
Sadly I’m no Regex expert but that seems to work.

Hi,

It’s because you set Mulitline option in regex101. (m (of ‘/gim’) at the end of pattern means Multiline)
Unfortunately, regex builder wizard has no option for it. Can you try check Multiline in Regex Option property?

Regards,

1 Like

Hi @TastyToast,

I have checked with your patterns still not getting the expected output

Thanks for the quick reply much appreciated

Regards,
Bala.S

Hi Yoichi,

Have tried with multiline property Still not working

Regards,
Bala.S

Hi,

Do you want to get just 17 digit number? If so, can you try the following sample?

Sequence.xaml (6.3 KB)

Regards,

I’d recommend using regexstorm.net/tester instead of other regex builders, since it is specifically made for vb.net

The following regex worked fine for me to find a 17-digit number starting with 21 or 11. Note that I added \b before & after the digits because I assumed you wouldn’t want a 18+ digit found.

\b(21|11)\d{15}\b

1 Like

Hi Yoichi,

Thanks for the your quick reply my input file will be data from excel sheet
still not able extract data
Can pls check input file as excel file and pass the same data to regex activity and please let me the your output

Regards,
Bala.S

1 Like

Hi,

How are you going to get data from Excel sheet? Will you use ReadRange activity?
If so, we need to manipulate DataTable.

Can you share your excel file, if possible? (It’s no problem even if dummy data)

Regards,

Hi Yoichi,

PFA input dummy Excel file and Xaml file for your reference
RegexTempData.xlsx (8.8 KB) Test.xaml (16.6 KB)
Regards,
Bala.S

Hi,
It is working with RegEx (11|21)\d{15}. I have tried with the excel that you have shared! Refer to the screenshot for the result.
UiPathRegEx|690x296

Regards,
Manohar

Hi Manohar,

I am able to extract data from the file but bot extract unwanted data too

In the Excel file, I have a bulk of data from the bulk data I want to extract only the starting of the number will be 11 or 21, and the length of the number is fixed (17)

Example : 1) 0D119460333472915000 2) 21951978287054300 3)11958358648178300 4)0D21951978287054300

Expected output :21951978287054300
11958358648178300

Regards,
Bala.S

1 Like

HI @BALASUBRAMANIAN,

Can you try this expression (11|21).\d{15}

Cheers
@BALASUBRAMANIAN

Hi Pradeep,

Checked with your patterns bot extract unwanted data too

Regards,
Bala.S

Then you need to first split the extracted data with a newline, store the result in an Array, and then iterate the array with your regEx “^(11|21)\d{15}”, finally store the matched pattern in a new array which would be your answer.
Hope you understand the steps mentioned above.

Best Regards,
Manohar

Hi Manohar,

PFA Dummy excel file with multiple column data set and share your Xaml File So that I can refer it

Regards,
Bala.SRegexTempData.xlsx (9.3 KB)

Hi,

Thank you for sharing your data.
Can you try the following sample?

Main.xaml (6.4 KB)

Regards,

Hi Yoichi,

I am able to fetch data only when Number is present in first column, Yoichi The data column posting is not fixed data can be located in the 3rd column or 8th column and so on.

Note : In the read range activity have to read Whole Input sheet.

Regards,
Bala.S

Test with the attached sequence. I have updated the code that convert the table to text to include the whole table and modified the regular expression slightly.

\b(11|21)\d{15}\b

ReadExcelReg.xaml (7.9 KB)

@BALASUBRAMANIAN - did you see my earlier answer? Was it not working as you expected? Unable to get matches to extract values using regex

1 Like