本文介绍了仿效占有欲量词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 是否有可能效仿占有欲量词(.NET不支持的话)用原子分组(或其他方式)?Is it possible to emulate possessive quantifiers (.NET doesn’t support it) using atomic grouping (or in other way)?请注意。我发现,(X + X +)++是可以换成(大于?(X + X +)+)Y ,但这仅仅是一个例子,我不知道是否总是 {东西} @ + 等于(大于{东西} @)(其中 @ 是一个量词)。Note. I found that (x+x+)++y can be replaced with (?>(x+x+)+)y, but this is just an example and I don’t know whether always {something}@+ equals to (?>{something}@) (where @ is a quantifier).推荐答案是啊。我可以引述自己掌握,杰弗里·弗里德尔,从他的经典精通正防爆pressions(第3版)第142页:Yup. May I quote the master himself, Jeffrey Friedl, from page 142 of his classic Mastering Regular Expressions (3rd Edition):从某种意义上说,占有欲量词只是语法糖,因为它们可以用固化分组来模仿他,像这样 + 具有完全相同的结果为(大于?+),但一个聪明的实现可以优化占有欲量词超过原子团 "In one sense, possessive quantifiers are just syntactic sugar, as they can be mimicked with atomic grouping. Something like .++ has exactly the same result as (?>.+), although a smart implementation can optimize possessive quantifiers more than atomic grouping." 这篇关于仿效占有欲量词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-10 23:28