Delete all lines starting with # or ; in Notepad++

前端 未结 5 1124
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 09:53

Using Notepad++, how do I remove all lines starting with # or ;?

5条回答
  •  醉梦人生
    2020-12-07 10:09

    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;
    

提交回复
热议问题