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

求教一个php正则替换话语

WBOY
Release: 2016-06-13 12:15:06
Original
946 people have browsed it

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

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

文中的数字每个是不一样的。
我想把这段文字里的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);
Copy after login
<li>标题<li><br /><li>标题<li><br />......<br /><li>标题<li><br />
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template