Regex uipath

Hi Team,

I have a text as mentioned below:
9,202.02
Due Date: TAX INVOICE
TOTAL DUE
140,659.47
30.OCT.2019

I have to read the amount below to the “Total Due” field from the text file. I’m using Regex as below:

System.Text.RegularExpressions.Regex.Match(Result,"(?<=(Total Due))\d+\s:(.*)(?=\s)").Value

This is returning an empty field. Ant help please?

Hi @chiru74,
Remember that regex might be case sensitive. In your expression there is to much brackets if I see correctly. Try this instead:
(?<=TOTAL DUE)\n[[:graph:]]+
image

2 Likes

I would suggest trying to build regex patterns using a tester. I have found this one to be helpful because it actually has the .net language: http://regexstorm.net/tester

Just putting something together really quickly, I came up with: TOTAL DUE\r\n([\d,\.]+)

Here’s how it looks:
image

3 Likes

Please don’t use regex101.com for UiPath. That does not have the .net language and any regex’s tested may not work as .net is dumb and does not have nearly as many features as other languages.

If you test that using .net, that does’t give anything:

Thanks for the reply…But I’m getting result as

TOTAL DUE
140,659.47

But the output I need is

140,659.47

Could you please suggest on this?

Thanks again

Are you using the match group?

You have to pull out the portion that was captured. If you just look at the match text, it will give you the whole match like you’re showing.

regexBetweenLabel.xaml (5.5 KB)

System.Text.RegularExpressions.Regex.Match(strInput,"(?<=TOTAL DUE)([\S\s]*)(?=(\d{2}.\w{3}.\d{4}))").Value.Trim

Thanks!

1 Like

@dmccammond,
You’re right about that. I totally forgot .net case. Thanks for being watchful :slight_smile:

1 Like

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