Using Notepad++, how do I remove all lines starting with # or ;?
Find:
^[#;].*
Replace with nothing. The ^
indicates the start of a line, the [#;]
is a character class to match either #
or ;
, and .*
matches anything else in the line.
In versions of Notepad++ before 6.0, you won't be able to actually remove the lines due to a limitation in its regex engine; the replacement results in blank lines for each line matched. In other words, this:
# foo ; bar statement;
Will turn into:
statement;
However, the replacement will work in Notepad++ 6.0 if you add \r
, \n
or \r\n
to the end of the pattern, depending on which line ending your file is using, resulting in:
statement;