Home >Backend Development >PHP Tutorial >求教一个php正则替换话语

求教一个php正则替换话语

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:15:06961browse

求教一个php正则替换语句
有一段文字,内容如下:

<br /><li id="数字">标题<li><br /><li id="数字">标题<li><br />......<br /><li id="数字">标题<li><br />

文中的数字每个是不一样的。
我想把这段文字里的id="数字" 去掉,语句该怎么写啊?谢谢!

------解决思路----------------------
$s =<<< TXT<br /><li id="123">标题<li><br /><li id="45">标题<li><br />......<br /><li id="6789">标题<li><br />TXT;<br /><br />echo preg_replace('/\sid="\d+"/i', '', $s);
<li>标题<li><br /><li>标题<li><br />......<br /><li>标题<li><br />

------解决思路----------------------
print_r ( preg_replace("/id=\"[\d]+\"/", '', $str) );

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn