I want a regular expression which will match one or more instances of text followed by a newline. Following the final match of text followed by a newline I would like for a single further newline, then no more. How would I go about achieving this?
I am having difficulty in enforcing the one new line rule.
My (wrong) attempts include:
[^\n]+\n\n
([^\n]+\n[^\n]+)*\n\n
An example of text i would like to match is:
"Hello text\nMore text\nLast one\n\n"
With a non-match on both:
"Hello text\nMore text\nLast one\n\n\n"
"Hello text\nMore text\nLast one\n"
PLease help me. thanks