為什么只匹配<b></b>里的字符串,而不會匹配<b></b>?
$p = "|<[^>]+>(.*?)</[^>]+>|i";
$str = "<b>example: </b><div align=left>this is a test</div>";
preg_match_all($p, $str, $matches);
print_r($matches);
$p = "|<[^>]+>(.*?)</[^>]+>|i";
$str = "<b>example: </b><div align=left>this is a test</div>";
preg_match_all($p, $str, $matches);
print_r($matches);
2017-04-17
舉報
2017-07-04
2017-07-04
2017-04-18
$p = "/<b>(.*?)<\/b>/i"; 拿我寫的這個舉例子 ? 你獲取到的有b標簽的會被存放在$matches[0]中,因為$matches[0]種存放的是匹配完整表達式的結果,$matches[1]存放的只是(.*?)匹配的結果,沒有包含前邊后邊的標簽
2017-04-18
$p = "/<b>(.*?)<\/b>/i";