regex - Match newlines except if it ends with semicolon -
i want match newline \n except when line ends semicolon. attempt far (?!;\n)\n matches newline doesn't exclude anything. sample text:
this line of text should match should exclude line; line should ignored; should match
to match \n
not preceded ;
in notepad++, can use
\n(?<!;\n)
or
(?<!;)\n
see regex demo
the (?<!...)
look-behind zero-width assertion checks not consume text before text match (the \n
symbol). tried look-ahead checks text right after text matched.
the same construct in vim \(....\)\@<!
:
\n\(;\n\)\@<!
or
\(;\)\@<!\n
Comments
Post a Comment