Home  >  Article  >  Backend Development  >  求教一个php正则替换语句

求教一个php正则替换语句

WBOY
WBOYOriginal
2016-06-23 13:40:19811browse

有一段文字,内容如下:

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

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


回复讨论(解决方案)

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

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