【问题标题】:Remove lines , But not space between two words in Notepad++删除行,但不是 Notepad++ 中两个单词之间的空格
【发布时间】:2017-05-17 11:24:35
【问题描述】:

我有以下几行:

example
example example
example example example
example example, example
example example example.
 example


example12
example example*
example example (example)
éxample example

我只想删除这几行:

example12
example example*
example example (example)
éxample example

像这样:

代码 1:

^(?![a-zA-Z,.']+$).+$\R?

代码 2:

^.*[^a-zA-Z.,'].*$

两个词之间的空格:

[ \t]+

【问题讨论】:

  • 您能用文字解释一下您的要求吗?您想删除任何包含除字母数字、逗号、句点和单引号字符之外的字符的行,并且...请继续。也许只是将\h 添加到字符类 - ^(?![a-zA-Z,.'\h]+$).+$\R?
  • 谢谢@WiktorStribiżew 先生,我只是想过滤英文文本,:) 它工作正常^^

标签: regex notepad++ notepad regex-group


【解决方案1】:

您似乎只需要确保空格也被视为有效字符,将其添加到第一个正则表达式的前瞻中:

^(?![a-zA-Z,.'\h]+$).+$\R?

使用\h 代替\s 以防止跳转到另一行。 \s 匹配换行符,\h 只匹配水平空格。

【讨论】:

    猜你喜欢
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 2014-07-30
    • 1970-01-01
    • 1970-01-01
    • 2016-04-16
    • 2016-06-10
    • 2014-10-01
    相关资源
    最近更新 更多