例子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 ? ? ? ?) )?
2015-08-21
$p = "|<[^>]+>(.*?)</[^>]+>|i";//這里會緩存兩個值,一個是全部匹配到的值,還有一個是括號里面正則所匹配到的值
$p = "|<[^>]+>(?:.*?)</[^>]+>|i";//將正則改為這樣就行了,?:的意思是取消后向引用,類似的解答可以訪問下面的網址
?http://www.xianlaiwan.cn/qadetail/93469?