Matches with Regex, Getting Error When Using Line Break (\n)



I have a very simple sequence that:
Reads a pdf with OCR, outputs as ReadPDF string variable
A Matches activity with a regex formula of “(?<=Order Number\n\n)\d{5}” that outputs an |Enumerable variable WorkOrder
And an Assign activity to put the result into a variable idOrder = WorkOrder(0).ToString

The Regex works in the test environment:

I am getting an error: Assign : Object reference not set to an instance of an object.

I’ve used the matches activity successfully many times before and I’m not sure why this isn’t working.
Is there anything I’m using in Regex that isn’t allowed in UiPath’s use of Regex or something?



Give a try with this pattern

(?<=Order Number[\n\r]+)\d{5}



Wow, exceptional.Thank you ever so much!!! This made my day,

Can you tell me how this works as opposed to what I was doing so I can understand this?

+1000 points to you!


Yes, this does not work in a regular Regex environment,
…it throws the following error: (+ A quantifier inside a lookbehind makes it non-fixed width)

…so can you possibly explain what it is that makes this work within UiPath? How you got this?

Again, thank you so much for your help, I really was struggling with this and not understanding why it wasn’t working.



There are simply several regex versions with different syntax.
UiPath is based on .Net so i prefer to use .Net tools.
I generally like to use which is quite simple and has nothing fancy.
Regarding the newlines it can appear on different forms depending on the environment, dealing with Microsoft apps will often be \r\n or so.