在 notepad++ 中搜索 .* 以删除单词之间
searching .* in notepad++ to delete between to words
我有一条短信
aabbccddeeaaee
我想删除 aa 和 ee 之间的内容,但我希望删除第一次出现的内容而不是整个内容。
当我搜索 aa.*e 时,它找到了 aabbccddeeaaee,但我想要 aabbccddeea。
尝试非贪婪匹配:
/aa.*?ee/
↑ non-greedy matching
通常情况下,*
量词会尽可能多地获取——这就是所谓的贪心匹配。要使其尽可能少地非贪婪地抓取,请使用 .*?
变体。来自 MDN:
x?
If used immediately after any of the quantifiers *
, +
, ?
, or {}
, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times).
我有一条短信
aabbccddeeaaee
我想删除 aa 和 ee 之间的内容,但我希望删除第一次出现的内容而不是整个内容。
当我搜索 aa.*e 时,它找到了 aabbccddeeaaee,但我想要 aabbccddeea。
尝试非贪婪匹配:
/aa.*?ee/
↑ non-greedy matching
通常情况下,*
量词会尽可能多地获取——这就是所谓的贪心匹配。要使其尽可能少地非贪婪地抓取,请使用 .*?
变体。来自 MDN:
x?
If used immediately after any of the quantifiers
*
,+
,?
, or{}
, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times).