我正在尝试进行此正则表达式匹配并替换但无法执行此操作.
例
<SPAN class="one">first content here</SPAN>
<SPAN class="two">second content here </SPAN>
<SPAN class="three">one; two; three; and more.</span>
<SPAN class="four">more content here.</span>
Run Code Online (Sandbox Code Playgroud)
我想找到每组span标签,并替换为这样的东西
找
<SPAN class="one">first content here</SPAN>
改成
<one>first content here</one>
与span标签的其余部分相同.
class="one",class="two"等等是我在正则表达式匹配表达式中使用的唯一键标识符.因此,如果我找到带有这些类的span标记,那么我想进行替换.我的主要问题是我无法找到第一个结束标记的出现,所以它的作用是从开始到结束找不到任何用处.到目前为止,我一直在尝试使用记事本++,但只是发现它有其局限性所以任何PHP帮助将不胜感激.
问候
Amy*_*y B 12
preg_replace('/<span class="(.*?)">(.*?)<\/span>/i', '<$1>$2</$1>', $input);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6600 次 |
| 最近记录: |