删除所有以 # 或 ; 开头的行在记事本++中 [英] Delete all lines starting with # or ; in Notepad++
问题描述
使用 Notepad++,如何删除所有以 # 或 ; 开头的行?
查找:
^[#;].*
替换为空.^
表示一行的开始,[#;]
是一个字符类来匹配 #
或 ;
和 .*
匹配行中的任何其他内容.
在 Notepad++ 6.0 之前的版本中,由于其正则表达式引擎的限制,您将无法实际删除这些行;对于匹配的每一行,替换结果为空行.换句话说,这是:
<前># 富;酒吧陈述;会变成:
<前>陈述;但是,如果您将 \r
、\n
或 \r\n
添加到末尾,则替换将在 Notepad++ 6.0 中起作用模式,取决于您的文件正在使用哪一行结束,导致:
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;
这篇关于删除所有以 # 或 ; 开头的行在记事本++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!