How to do conditional "or" in regex?

Good afternoon friends, I am trying to capture two figures, but the currency symbol is different, I have tried with the “or” in regex, but it seems that I am not doing it correctly.

failed attempts:

(?<=OP. GRAVADA S/ ).{1,10}
(?<=OP. GRAVADA ($|S/) ).{1,10}

independent lines: In each pdf there is only one data in one of the two types of currency

OP. GRAVADA S/ 1,397
OP. GRAVADA $ 51.13

expected result:

1,397
51.13

Hi @Lynx

The pipe symbol “|” represents Or in Regex.

Take a look at this Regex Pattern I have created for you.
image

I have used an achor on the text “OP. GRAVADA” and then inserted some brackets which will find either “S/” or “$” (note that “$” must be escaped “\$” like this to mean it literally instead of the end of a line).

Just be aware that Regex101.com is great for learning and for ‘basic’ Regex Patterns but I strongly recommend using RegexStorm as it is 100% compatible with UiPath (as far as I know :slight_smile:). You can Regex101.com but always check your pattern in RegexStorm before inserting into UiPath.

Cheers

Steve

1 Like

Thanks a lot @Steven_McKeering

1 Like

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