Notepad++ 显式量词符号 [英] Notepad++ explicit quantifier notation
问题描述
我一直在使用 Notepad++ 正则表达式引擎,但有一些我无法工作,它是显式量词符号.
I've been playing around with the Notepad++ regular expression engine, but there's something I can't make work, it's the explicit quantifier notation.
我在这里看到了其他一些使用以下语法的帖子:(expr){1,2}
I've seen some other posts here where the following syntax is used : (expr){1,2}
但是,当我在像 k{1,1}
这样简单的测试中使用它时要搜索的文本是 k :没有匹配项.我尝试了很多语法:{1、}、{1} 等.我在这里错过了什么吗?
However, when I use it in a test as simple as k{1,1}
where the text to search is k : there is no match.
I tried a lot of syntax's : {1,}, {1}, etc.
Am I missing something here ?
请原谅我的英语不好,感谢您的回答!
Please excuse my bad english, and thanks for your answers !
推荐答案
从 6.0 版本开始,Notepad++ 支持 PCRE (来源).量词将在这些版本中按预期工作.
Starting with version 6.0, Notepad++ supports PCRE (source). Quantifiers will work as expected in these versions.
Notepad++ 5.9.8 及更低版本的正则表达式引擎不支持量词(来源).
The regex engine of Notepad++ 5.9.8 and lower does not support quantifiers (source).
但是,您可以使用以下量词:
You can, however, use the following quantifiers:
k*
,相当于k{0,}
.k+
,相当于k{1,}
.k?
,相当于k{0,1}
.
k*
, which is equivalent tok{0,}
.k+
, which is equivalent tok{1,}
.k?
, which is equivalent tok{0,1}
.
如果需要其他量词,可以结合上述方法.
If you want other quantifiers, you can combine the above methods.
示例:
kkk+
模拟k{3,}
kkkk?k?
模拟k{3,5}
kkk+
emulatesk{3,}
kkkk?k?
emulatesk{3,5}
这篇关于Notepad++ 显式量词符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!