有人可以向我解释所有格量词吗? (常用表达)
我正在阅读 PCRE 文档,它引用了所有格量词,但没有明确或具体定义它们。 我知道什么是贪婪量词,也知道什么是惰性量词。 但占有欲强?
PCRE 手册页 在使用该术语而不对其进行定义时似乎是作弊。 手册页特别指出术语“所有格量词”首先在 中定义弗里德尔的书。 嗯,那太好了,但是我没有弗里德尔的书,在阅读手册页时,我无法弄清楚所有格量词与贪婪量词的区别。
- ? = 零或一,贪心
- ? = 零或一,懒惰
- ?+ = 零或一,所有格
- '+' = 1 或多个,贪婪
- +? = 一个或多个,惰性
- ++ = 一个或多个,所有格
I am reading the PCRE doc, and it refers to possessive quantifiers, but does not explicitly or specifically define them. I know what a greedy quantifier is, and I know what a lazy quantifer is. But possessive?
The PCRE man page seems to be cheating when it uses the term without defining it. The man page specifically states that the term possessive quantifiers was first defined in Friedl's book. Well, that's great, but I don't have Friedl's book, and in reading the man page, between the lines, I cannot figure out what distinguishes possessive quantifiers from greedy ones.
- ? = zero or one, greedy
- ?? = zero or one, lazy
- ?+ = zero or one, possessive
- '+' = one or more, greedy
- +? = one or more, lazy
- ++ = one or more, possessive
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许最好的起点是正则表达式教程 - 所有格量词:
Perhaps the best place to start is Regex Tutorial - Possessive Quantifiers: