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
>Solution :
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.