為什么只匹配<b></b>里的字符串,而不會(huì)匹配<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
舉報(bào)
2017-07-04
2017-07-04
2017-04-18
$p = "/<b>(.*?)<\/b>/i"; 拿我寫的這個(gè)舉例子 ? 你獲取到的有b標(biāo)簽的會(huì)被存放在$matches[0]中,因?yàn)?matches[0]種存放的是匹配完整表達(dá)式的結(jié)果,$matches[1]存放的只是(.*?)匹配的結(jié)果,沒(méi)有包含前邊后邊的標(biāo)簽
2017-04-18
$p = "/<b>(.*?)<\/b>/i";