例子1 $str = "<b>example: </b><div align=left>this is a test</div>";
$p = "|<[^>]+>(.*?)</[^>]+>|i"; 能帮我解释下么?为什么运行结果进行匹配了两次~
Array ( [0] => Array ( [0] => example: [1] =>
this is a test
) [1] => Array ( [0] => example: [1] => this is a test ) )
$p = "|<[^>]+>(.*?)</[^>]+>|i"; 能帮我解释下么?为什么运行结果进行匹配了两次~
Array ( [0] => Array ( [0] => example: [1] =>
this is a test
) [1] => Array ( [0] => example: [1] => this is a test ) )
2015-08-21
$p = "|<[^>]+>(.*?)</[^>]+>|i";//这里会缓存两个值,一个是全部匹配到的值,还有一个是括号里面正则所匹配到的值
$p = "|<[^>]+>(?:.*?)</[^>]+>|i";//将正则改为这样就行了,?:的意思是取消后向引用,类似的解答可以访问下面的网址
举报