使用PHP 进行简单正则替换
求一个简单的正则公式
code name="hello1" version="2012"<br />
code name="123" version="2012"<br />
code name="代码" version="2012"<br />
Copy after login
使用正则整替换成如下格式
code name="20121226-001" version="2012"<br />
code name="20121226-002" version="2012"<br />
code name="20121226-003" version="2012"<br />
Copy after login
------解决方案--------------------$s=<<
codes name="name1"
code name="hello1" version="2012"<br />
code name="123" version="2012"<br />
code name="代码" version="2012"<br />
HTML;
$i=0;
echo preg_replace('/"(.+)"(?=\s+version)/em','"\""."20121226-00".++$i."\""',$s);
Copy after login
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