Home > Mobile >  Optional parts of regex pattern in vba
Optional parts of regex pattern in vba

Time:03-23

I am trying to build regex pattern for the text like that

numb contra: 1.29151306 number mafo: 66662308
numb contra 1.30789668number mafo 60.046483
numb contra/ 1.29154056 number mafo: 666692638
numb contra     137459625
mafo: 666692638
mafo: 666692638 numb contra/ 1.29154056

Here's the pattern I could build

contra?.\s ?(\d \.?\d )(. mafo.?\s (\d \.?\d ))?

It works fine for all the lines except the last one. How can I implement all the possibilities to include the last line too?

Please have a look at this link enter image description here

Notice I added a line to your data that had two contra entries and one mafo and it found all the occurrences. You should be able to modify this to interpret the meanings.

  • Related