I would like to know how to create a RegEx with Python for the following issue:
I got a textfile with data in it, the regex should only match if:
- it has the right ID
- and does not include a specific value2 or value3 within the textfile (which can occur anywhere)
Textfile:
blabla
ID
blabla
...
blabla
value1
blabla
...
blabla
value2
blabla
...
This
(?<!\n)(\n.*(ID)(?!\n.*(value2|value3).*)
works, but only if value2 or value3 is on the line before or right after the line ID.
So, how to look up any line before and after the line ID? The solution should fit a single line of code like my try above.