0

I've been reading this post Return only one group with OR condition in Regex to get an understanding how to get only one group in match. Somehow that does not work on my pattern.

Here is the used string:

Ledigingen 4 lediging € 32,48 € 50,92 21,00 %
van 01-01-2019 t/m 31-01-2019
Huur 1 Maand € 8,63 € 8,63 21,00 %
toeslag over € 50,42 (21% BTW) € 2,76 21,00 %
(WHITESPACE) Totaal exclusief BTW € 50,18 
BTW hoog (21%) € 50,18 € 50,89 
totaal inclusief BTW € 70,07

Currently it extracts each occurence of amount. Is there a way to get only values followed by [Tt]otaa?l excl/incl BTW?

I guess I've been using positive/negative lookahead wrong.

Desired output from the given input is:

€ 50,18
€ 70,07

DEMO

RegEx

(?!<=[tT]otaa?l\s*?.*?)([€$]\s*\d+(?:[,.]\d{0,2})?)
Toto
  • 89,455
  • 62
  • 89
  • 125
rumba
  • 13
  • 2
  • Did you read the regex explanation at regex101? – Toto Mar 19 '19 at 14:21
  • [Is this OK](https://regex101.com/r/PuGrqn/7) – Toto Mar 19 '19 at 14:30
  • @Toto I am looking for a way to extract only values with this mask €$ dd.dd. And the pattern should be stable in case string has only i.e. totaal incl/totaal excl with or without BTW . I added ([A-Z]{3})*? in your pattern for cases when there is no BTW. But how to get only amount now? https://regex101.com/r/PuGrqn/11 – rumba Mar 19 '19 at 15:08
  • With [this one](https://regex101.com/r/PuGrqn/13), the amount is found in group 1 – Toto Mar 19 '19 at 15:13
  • Are you using python or another language? – Toto Mar 19 '19 at 15:15
  • Single use of regex, is there a way to extract get only 1st group values? Like for instance here https://regex101.com/r/PuGrqn/16 – rumba Mar 19 '19 at 15:37
  • If you can use PCRE regex flavour, [here is a way](https://regex101.com/r/PuGrqn/20) – Toto Mar 19 '19 at 16:51
  • nice one, although uipath(tool that i use) does not support PCRE, is there any workaround here? – rumba Mar 19 '19 at 17:41

0 Answers0