时间:2021-07-01 10:21:17 帮助过:5人阅读
输出: array (size=1) 0 => string 'abcde' (length=5) array (size=1) 0 => array (size=3) 0 => string 'abcde' (length=5) 1 => string 'abcde' (length=5) 2 => string 'abcde' (length=5) */ ?>2.贪婪模式和非贪婪模式的区别
string 'http://www.baidu/.com?url=www.sina.com' (length=38) 1 => string '//www.baidu/.com?url=www.sina.' (length=30) array (size=2) 0 => string 'http://www.baidu/.com' (length=21) 1 => string '//www.baidu/.' (length=13) */ ?>3.preg_match_all参数PREG_PATTERN_ORDER(默认)和PREG_SET_ORDER的区别
]+>(.*)[^>]+>|U", "start: this is a testend", $out1); var_dump($out1); echo('PREG_SET_ORDER'); preg_match_all("|<[^>]+>(.*)[^>]+>|U", "start: this is a testend", $out2, PREG_SET_ORDER); var_dump($out2); /* PREG_PATTERN_ORDER array (size=2) 0 => array (size=3) 0 => string 'start: ' (length=14) 1 => string 'this is a test' (length=21) 2 => string 'end' (length=10) 1 => array (size=3) 0 => string 'start: ' (length=7) 1 => string 'this is a test' (length=14) 2 => string 'end' (length=3) PREG_SET_ORDER array (size=3) 0 => array (size=2) 0 => string 'start: ' (length=14) 1 => string 'start: ' (length=7) 1 => array (size=2) 0 => string 'this is a test' (length=21) 1 => string 'this is a test' (length=14) 2 => array (size=2) 0 => string 'end' (length=10) 1 => string 'end' (length=3) */ ?>
http://www.bkjia.com/PHPjc/894184.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/894184.htmlTechArticlephp中preg正则函数使用 1.preg_match和preg_match_all的区别 preg_match和 preg_match_all区别是preg_match只匹配一次。而preg_match_all全部匹配,直到字符串结...