I have a text file with a data set I want to remove some records from. It looks like this:
- =separator=
- data
- unwantedKeyword
- data
- =separator=
- data
- wantedKeyword
- data
- =separator=
- data
- unwantedKeyword
- data
- =separator=
- data
- wantedKeyword
- data
- =separator=
I can use a certain keyword to identify records I don't want (or want). I wanted to use RegEx utilizing this keyword and a separator string to remove all those expressions. Removing the "bottom" part of the record works fine, but when I try to remove the "top" bit using this:
=separator=.*?unwantedKeyword
the start of the match is on the 1st available =separator= (line 5.) rather than the last one (line 9.) before the end keyword (line 11.) resulting in wanted records being removed.
Is it possible to match only the last instance of that string (=separator= in the mock data) so only lines 1. to 3. and 9. to 10. rather than 1. to 3. and 5. to 11. would be replaced?
EDIT:
Or I guess just make it read the file in backward direction? Notepad++ disables that option for RegEx tho, so not sure if that's possible either.
