有没有php正则修正符 U 的详细教程?经常用到 ##isU 这种正则,但U的理解很模糊,有人说是贪婪匹配,有人说是非贪婪,有人说是贪婪非贪婪两者之间互转,搞得一头雾水。求高手给个正确引导,到底怎么理解U修正符.如
preg_match_all("#\.hello\{.*\}#isU",$str,$result);

解决方案 »

  1.   

    看看PHP手册上的解释
    http://www.php.net/manual/en/reference.pcre.pattern.modifiers.phpThis modifier inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by ?.就是#\.hello\{.*\}#isU,这样子是非贪婪模式
    如果在前面的代码中加了?,#\.hello\{.*?\}#isU就是贪婪模式
    U就是一个贪婪/非贪婪的反向符