I'm trying to use NP++ regex to parse data from a file with input:
badstring ---
useless data
keyword1 ---
usless data
string 1 ---
random number of useless lines of characters across newlines
string 2 ---
more useless stuff
keyword2 ---
useless data
dumb badstring keyword2 ---
output:
string 1, string 2
For example sake, string1, string 2 and badstrings all have the same format, that's why I exclusively want to find string1 and string2 ONLY between keyword1 and keyword2.
The closest I was able to get is:
keyword1\r\n((.|\r\n)+?)\r\n(.+) ---\r\n((.|\r\n)+?)\r\n(.+) ---\r\n((.|\r\n)+?)keyword2
the problem is that I dont know the number of strings I need to capture, so I need to recursively search from the largest number of possible strings, and because I am using ((.|\r\n)+?) to match anything it always matches beyond the keyword, so when I run keyword1 ---((.|\r\n)+?)(.+) ---((.|\r\n)+?)(.+) ---((.|\r\n)+?)(.+) ---((.|\r\n)+?)keyword2 ---
to find 3 strings it selects beyond keyword2 because the next section also contains keyword2 instead of returning no matches. Similarly if I do it searching for too many strings it will loop around and select the entire file. Any ideas?