【问题标题】:Notepad++ Regex to find multiple words in a document?Notepad ++正则表达式在文档中查找多个单词?
【发布时间】:2016-05-27 18:58:37
【问题描述】:

我正在我的文档中查找以下单词:

"substr" 
"500"
"description"

我正在使用以下表达式来尝试匹配:

(substr|500|description)

这可以找到这些词中的任何一个,但我想跳转到只包含所有这些词的行。有没有办法做到这一点?我不想要 OR 条件,我想要 AND 对所有这些词。

例如:

test substr line one
test substr, 500 line two
test substr, 500, description line three <<--- only go to this line when I hit next!!

这可能吗?

【问题讨论】:

  • 您是否正在寻找以相同顺序出现的单词?
  • 不,顺序不一定重要,但单词确实以规则模式出现在每一行。无论如何,我只想转到以任何特定顺序包含所有这些单词的行。

标签: regex search notepad++


【解决方案1】:

要以任何顺序匹配它们,您可以使用 positive lookaheads ?=:

((?=.*\bsubstr\b)(?=.*\b500\b)(?=.*\bdescription\b).*)

按照给定的顺序匹配它们要容易得多:

.*substr.*500.*description.*

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多