gpt4 book ai didi

regex - Notepad++ Regex 在文档中查找多个单词?

转载 作者:行者123 更新时间:2023-12-01 06:59:04 24 4
gpt4 key购买 nike

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

"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!!

这可能吗?

最佳答案

要以任何顺序匹配它们,您可以使用正向预测 ?= :

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

按照给定的顺序匹配它们要容易得多:
.*substr.*500.*description.*

关于regex - Notepad++ Regex 在文档中查找多个单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37490572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com