Notepad++ 非贪婪正则表达式 [英] Notepad++ non-greedy regular expressions
本文介绍了Notepad++ 非贪婪正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Notepad++ 是否支持非贪婪的正则表达式?
Does Notepad++ support non-greedy regular expressions?
例如文本:
abcxadc
我想使用模式获取零件:
I want to get parts using pattern:
a.+c
现在我得到了整个字符串而不是两个部分.我尝试使用?"运算符但没有成功.
And now I get whole string instead of 2 parts. I tried to use the '?' operator but without success.
推荐答案
注意:此已接受的答案自 2011 年 3 月 31 日起已过时.Notepad++ v5.9 及更高版本现在支持非贪婪的正则表达式.
请在此处或此处.
Notepad++ 不支持惰性 ?
修饰符.相反,您可以指定您不想要的内容:
NOTE: This accepted answer is obsolete as of March 31, 2011. Notepad++ v5.9 and higher now support non-greedy regular expressions.
Please see an updated answer here or here.
Notepad++ doesn't support the lazy ?
modifier. Instead, you can specify what you don't want:
a[^c]+c
指定:匹配a
,后跟一个或多个不是c
的字符,后跟c
.这将匹配 abc
和 adc
.
Which specifies: match a
, followed by one or more character that isn't c
, followed by c
. This will match abc
and adc
.
这篇关于Notepad++ 非贪婪正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文