Reputation: 13
I'm very new to regex, what I'm trying to do is to match a line only if the next line is an empty line.
For example:
In the previous example, I would like to be able to select only line 1,5,7.
Is this possible with regex in notepad++?
Thanks in advance.
Upvotes: 1
Views: 523
Reputation: 174696
You could try the below positive lookahead based regex.
^.*?\S.*(?=\n[ \t]*$)
\S
matches any non-space character. So .*?\S.*
matches the line which has at-least one non-space character and the following (?=\n[ \t]*$)
asserts that the match must be followed by a newline character and then followed by zero or more space or tab characters.
OR
^.*?\S.*(?=\n\n)
If you mean empty line as line which don't have any single space or tab characters, then you could use the above regex. (?=\n\n)
asserts that the match must be followed by a blank line.
Upvotes: 1
Reputation: 985
You can use this regex,
(.*)\n\s*\n
and replace with
\1
It uses a concept of group capture, so here you can use \1
to use captured group, that is line before newline
Upvotes: 2
Reputation: 364
This should do the trick:
/(.)*\n\n/
If you're looking for an easy way to test / verify regex rubular is pretty good.
Upvotes: 0