TITLE
——
1 nuit
1 nuit
1 nuit
1 nuit
1 nuit
total : 5 nuits
——
1 nuit
1 nuit
1 nuit
total : 3 nuits
——
1 nuit
1 nuit
1 nuit
1 nuit
1 nuit
1 nuit
and so on ...
I'm having this paragraph in which I'd like to select the last lines after the occurrence of the last ——.
It should match and group the 6 following lines right after the ——... I've tried pretty much everything that crossed my mind so far but I must be missing something here.
I tested (?s:.*\s)\K—— that is able to match the last —— of the document. But I can't seem to be able to select the lines after that match.
The point here is to count the lines after that. So if I'm only able to select the "1" or "nuit" that's fine.
The expected capture:
1 nuit
1 nuit
1 nuit
1 nuit
1 nuit
1 nuit
You could write the pattern like this if there is no single dangling
——at the bottom, but that would give you a single match of all the lines:Regex demo
If you want separate matches (to count them), you could write the pattern as:
The pattern matches:
(?:Non capture group[\s\S]*Match all the way to the end of the file^——$Match——on a single line|Or\G(?!^)Assert the current position at the end of the previous match, not at the start)Close the non capture group\R\KMatch a newline and then forget what is matched so far.+Match a whole line with one or more charactersRegex demo
Or if there can not be a single
——at the bottom:Regex demo
For example in a tool like Notepad++: