新手问题 Regexp (?>pat) 理解

LinuxGit · 2012年08月05日 · 最后由 xds2000 回复于 2012年08月06日 · 2224 次阅读

ruby doc 的解释是“Grouping can be made atomic with (?>pat). This causes the subexpression pat to be matched independently of the rest of the expression such that what it matches becomes fixed for the remainder of the match, unless the entire subexpression must be abandoned and subsequently revisited. In this way pat is treated as a non-divisible whole. Atomic grouping is typically used to optimise patterns so as to prevent the regular expression engine from backtracking needlesly.” 😢看不懂,哪位可以举个简单的例子说明一下,谢谢。

原子性分组,保证递归匹配失效。没用过。用骨哥找几个吧

需要 登录 后方可回复, 如果你还没有账号请 注册新账号