Hello I need to find regex that would get middle section of this text:
# Command // first line with symbol character
First line of interest
Second line of interest
\n
Third line of interest
\n
\n // I am not interested in trailing new lines.
How could I get text starting with First line of interest and ending wint third line of interest? Thank you.
output:
The match starts at the beginning (
^in MULTILINE mode) of the first line that does not start with a hash symbol ((?!#)), but does contain characters other than line separators (.+, not.*).[\r\n]+matches one or more line separators, whether they be the Unix (\n), DOS (\r\n), or older-Mac (\r) style of separator. You should always be prepared to handle any or all of the different line separators, no matter what platform your code is running on.(?:[\r\n]+.+)*, then, matches zero or more additional lines, without matching any trailing line separators.