Reputation: 45
Can someone help me fix this notepad++ regex so that it will replace the text \N
with a space?
((?=.*?,Default)[^\r\n]*)(\N)
I'm looking to replace all instances of the text \N
only on lines that have ,Default
on it.
Upvotes: 1
Views: 585
Reputation: 626806
I suggest
(?:\G(?!^)|^(?=.*,Default)).*?\K\\N
See the regex demo.
Details:
(?:\G(?!^)|^(?=.*,Default))
- a start of the line location that contains ,Default
substring (^(?=.*,Default)
) or the end of the previous successful match (\G(?!^)
, as \G
matches the start of string/line, its position must be subtracted with a negative lookahead).*?
- any 0+ chars other than line break chars, as few as possible\K
- a match reset operator\\N
- a literal \N
substring.A test in Notepad++:
\NSome text,Default\Nand more here\N
\Ntext \N text ,Default
New line \N\N\N
Upvotes: 1