Maison >développement back-end >tutoriel php >求截取PHP指定字符串代码,该怎么解决
求截取PHP指定字符串代码
有下面一段html字符串:
$s = '<td align="Center" rowspan="2" width="7%">aaaa<br>bbbb<br>cccc<br>dddd<br></td >';<br />echo preg_replace('/<br>\w+/', '', $s, 2);
<td align="Center" rowspan="2" width="7%">aaaa<br>dddd<br></td ><br />
echo preg_replace('/<br>[^<]+/', '', $s, 2);
echo preg_replace('/\(.+?\)/', '', $s);
echo preg_replace_callback('/<br>[^<]+/', 'foo', $s, 2); <br />function foo($m){<br /> return strpos($m[0], '(') !== false ? preg_replace('/\(.+?\)/','',$m[0]) : ''; <br />}