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:


Hi @Lynx

The pipe symbol “|” represents Or in Regex.

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

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 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 but always check your pattern in RegexStorm before inserting into UiPath.



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.