2012-02-29 117 views

回答

9

这里有两个正则表达式。第一个是:

\G # the end of the previous match 
".*?" # something in quotes 
(,|$) # and a comma, or the end of the string 

如果第一个失败,第二次将被匹配:

\G # the end of the previous match 
[^,]* # anything up to the next comma or end of string 
(,|$) # and then a comma, or the end of the string 

我的猜测是两个正则表达式的设计,以配合一些东西,可以被引用或不引用,并可能会在逗号后跟着一些更多的项目。

(该c修饰符意味着保持当前的位置,如果匹配不成功,所以\G锚不会在第二次尝试,如果第一个匹配失败而改变。该g修饰符设置为下一个用于\G位置匹配 - 等等)。

0

第一个表示匹配引号后面跟随逗号或字符串结尾的每个字符串(即/gc)。第二种意思是匹配0或更多(即*)非逗号字符(即[^,])的任何序列。请注意,\G修饰符意味着每个新比赛必须在上一场比赛之后立即开始。

相关问题