代码之家  ›  专栏  ›  技术社区  ›  S Andrew

如何在notepad++中同时搜索两个项目

  •  0
  • S Andrew  · 技术社区  · 6 年前

    我有一个非常大的文件,大小超过30Mb。它包含如下文本:

    "Data1" "Data2" "Data3" "time1" "time2" "time3" "Data4" "Data5" "Data6" "time4" "time5" "time6"
    

    像上面这样的台词还有很多。假设我想寻找 Data2 Data4 但与此同时,搜索一次只接受一个项目。

    如何一次搜索两个项目。

    2 回复  |  直到 6 年前
        1
  •  1
  •   zwer    6 年前

    你可以用 regex -在 Find 对话,根据 Search Mode 选择 Regular expression (并确保 . matches newline

    Data2.*Data4
    

    或者,如果你不在乎订单:

    Data2.*Data4|Data4.*Data2
    
        2
  •  1
  •   Archu Mohan    6 年前

    只需选择regularexpression作为搜索模式 并在搜索文本中显示为data2 | data4

        3
  •  0
  •   Toto    4 年前

    这是一个前瞻性的工作:

    • +
    • 查找内容: ^(?=.*\bData2\b)(?=.*\bData4\b).+$
    • $1,$2,$3,$4\n
    • 检查 匹配大小写
    • 检查
    • 检查 正则表达式
    • 取消选中 . matches newline
    • 查找下一个
      • 或者

    ^               # beginning of line
      (?=           # positive lookahead, make sure we have after:
        .*              # 0 or more any character but newline
        \b              # word boundary
        Data2           # the string to search
        \b              # word boundary
      )             # end lookahead
      (?=           # positive lookahead, make sure we have after:
        .*              # 0 or more any character but newline
        \b              # word boundary
        Data4           # the string to search
        \b              # word boundary
      )             # end lookahead
      .+            # 1 or more any character but newline
    $               # end of line
    

    Demo

    Further reading about lookaround

    ^(?=.*\bData1\b)(?=.*\bData2\b)(?=.*\bData3\b)(?=.*\bData4\b).+$
    

    Data1 & Data2 & Data3 & Data4