notepad++ - substring replacement regex -


add semicolon (;) end of every line.

this have: ([^\n])$

the problem takes last characther out instead of adding semicolon on end.

also, using notepad++

i assuming here pattern intentional, in want match line-endings of non-empty lines. (if want match lines, remove ([^\n]))

in replace with field need write match character:

$1; 

obviously, match replaced, if match character before end of line, it's going replaced. if wrap in parentheses (like did), it's captured , can referred in replacement string.

alternatively, can use lookbehind, checks condition not include contents in match:

(?<=[^\n])$ 

this way, can replace ;. in case doesn't make difference. in performance-critical scripts more complicated expressions, capturing tends expensive operation, lookarounds favorable.


Comments