Reputation: 443
Why does the following pattern not match only two or more consecutive blank lines? (Including regex flag : Multiline)
/(^\s*$){2,}/m
Using Regex101, I see that it matches (for example) the first single blank line of example below (note, I did use ALT-255 for the first character in the block quote below just to represent a starting blank line, remove it if you copy the example text):
some text after the first blank line
more text
// comment after a space
// comment after 2 blank lines
text
// comment
// comment
How can I tweak this to match 2 or more blank lines only?
Upvotes: 1
Views: 2422
Reputation: 155
If you also want to include 2 or more consecutive blank lines which may or may not have whitespace characters in the lines:
(^\s*\n{2,})
Upvotes: 0
Reputation:
Regex you should be using is ^\n{1,}$
This will look for 2 or more
blank newlines.
Upvotes: 4