简体   繁体   English

Notepad ++如何删除没有2个空格字符的行

[英]Notepad++ How to remove line without 2 space character

I can remove line without 1 space character with notepad++我可以用记事本++删除没有1个空格字符的行

^[^ ]*$

How to remove line without 2 space character.如何删除没有 2 个空格字符的行。

I guess, maybe you want to remove lines with 1 space and 3 or more, maybe then我想,也许你想删除 1 个空格和 3 个或更多的行,也许那时

^ {1}$|^ {3,}$

might be OK to look into.可以调查一下。


If you wish to simplify/modify/explore the expression, it's been explained on the top right panel of regex101.com .如果您想简化/修改/探索表达式,它已在regex101.com的右上角面板上进行了解释。 If you'd like, you can also watch in this link , how it would match against some sample inputs.如果您愿意,您还可以在此链接中观看它如何与一些示例输入匹配。


RegEx Circuit正则表达式电路

jex.im visualizes regular expressions: jex.im可视化正则表达式:

在此处输入图像描述

To match a line that does not contain 2 spaces, you could use a negative lookahead asserting not 2 times a space using \S* to match zero or more times a non whitespace char.要匹配不包含 2 个空格的行,您可以使用否定前瞻断言不是 2 次空格使用\S*匹配零次或多次非空白字符。

^(?!\S* \S* \S*$).+$
  • ^ Start of string ^字符串开头
  • (?! Negative lookahead, assert what is on the right is not (?!负前瞻,断言右边的不是
    • \S* \S* \S*$ Match 2 spaces between 0+ non whitespace chars \S* \S* \S* \S*$匹配 0+ 非空白字符之间的 2 个空格\S*
  • ) Close lookahead )关闭前瞻
  • .+ Match any char 0+ times except a newline .+匹配任何字符 0+ 次,换行符除外
  • $ End of string $字符串结尾

Regex demo正则表达式演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM