RegEx help - Invoice Extraction

Hi,

I have tried the below regex patter in https://regex101.com/ and also in RegExr: Learn, Build, & Test RegEx it is extracting the results…Here is my inputtx and Regex pattern.output.txt (419 Bytes)

(?<=Number\sAmount\sDue\s(INR))[\r\n]^(.+?).

But When I tried the same thing in uipath it is not working. Getting the below error:
image .

I have tried the same pattern in .NET Regex Tester - Regex Storm , It came back with No match.

Any help? How to resolve this? and why there is a discrepancy between regex testing websites??

If you are trying to extract “Rahul Jignesh”, test with this pattern:

(?<=Number\sAmount\sDue\s\(INR\)[\r\n]+)(.+?)(?=\.)

@ptrobot – Thanks …in your opinion which is the best website for RegEx tetsing?

@prasath17 You’re welcome!

I would say that Regex Storm is the best since it’s made specifically for testing regular expressions in .NET (which is what UiPath is using).

What is Regex Storm?

Regex Storm helps you build and test regular expressions in .NET. There are a lot of online regex testers out there, but my goal was to make a good one specifically for .NET developers.

1 Like

Hi @prasath17

This is the same question I have asked of the forums and had @Yoichi answer before :blush:

Further to @ptrobot’s post,

RegexStorm is the MOST compatible site with UiPath, but please note there are still some small differences between UiPath and RegexStorm.

For example:
In RegexStorm,
“^” = the start of the entire string
“$”= the end of an entire string

But in UiPath
“^” = the start of a single line.
“$”= the end of a single line.

The simplest of differences can make solving a pattern easier. Lots of forum users use Regex101.com simply because you can share your Regex Pattern - that’s it.

I regularly use both sites. With regex101.com to share with others or RegexStorm if its just me figuring out a pattern.

If you want to Learn Regex - feel free to check out my Regex MegaPost:

If in doubt - make a post (like you did) and you will get assistance from the community :slight_smile:

Hopefully this helps :slight_smile:

2 Likes

@Steven_McKeering Regarding the difference with ^ and $, is it documented anywhere or have you found it out by trial and error?

According to Microsoft ^ should match the beginning of a string, unless the multiline option is specified, in which case it will match the start of each line.

Start of String or Line: ^

By default, the ^ anchor specifies that the following pattern must begin at the first character position of the string. If you use ^ with the RegexOptions.Multiline option (see Regular Expression Options), the match must occur at the beginning of each line.

Source: Anchors in .NET Regular Expressions - .NET | Microsoft Learn

Hello @ptrobot

Just trial and error :blush:

I am not a VB.Net guru.

Strangely enough this change for ^ and $ works on Regex101.com.

@Steven_McKeering Thank you for your reply. Out of curiosity, I did a quick test with the Matches activity in UiPath Studio. It seems to be working according to Microsoft’s description so it doesn’t seem to be any difference in this regard with UiPath and RegEx Storm anymore.

image


2 Likes

Hey

I must have gotten mixed up :wine_glass:

If I remember what the difference is I’ll post it.

@Yoichi can you recall?

1 Like

Hi @Steven_McKeering ,

I think Regex Storm is basically same as UiPath regex because of .net regex as @ptrobot mentioned.

“^” = the start of a single line.
“$”= the end of a single line.

It’s behavior of Multiline option and this option is set true as default in regex101.
It might be the cause of mixed up.

Regards,

2 Likes

Thanks @Yoichi and @ptrobot

I am still learning something new every day!

Glad to clear that up! :blush:

1 Like

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