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

求教一个php正则替换语句

WBOY
Release: 2016-06-23 13:40:19
Original
830 people have browsed it

有一段文字,内容如下:

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

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


回复讨论(解决方案)

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

print_r ( preg_replace("/id=\"[\d]+\"/", '', $str) );

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