I tried to detect duplicate blank lines with
\s*\n\n+
https://regex101.com/r/v0imUZ/1
but doesn't seem to work with
test1
test2
test3
test4
test1
test2
test3
test4
I tried to detect duplicate blank lines with
\s*\n\n+
https://regex101.com/r/v0imUZ/1
but doesn't seem to work with
test1
test2
test3
test4
test1
test2
test3
test4
You can use
\n(?:[^\S\n]*\n)+
See the regex demo. If there can be CRLF endings:
\r?\n(?:[^\S\n\r]*\r?\n)+
Details:
\r? - an optional carriage return symbol\n - a newline char(?:[^\S\n]*\n)+ - one or more occurrences of
[^\S\n]* - zero or more whitespace chars excluding newline char, and then\n - a newline char.
\s*will also match newline characters./\n{2,}/matches 2 or more line breaks. OP needs to match two or more blank lines./\n[^\S]+/matches a newline and then one or more whitespace chars (not necessarily a newline). Basically, neither is the solution.