preg_replace嵌套的html标签

时间:2017-06-22 00:34:04

标签: php html regex

我想转换常规嵌套的html标签:

<section class="foo">
<h1>My title <span style="color:#F00;">is awesome</span></h1>
<a href="#blog"><img src="assets/img/blog.jpg" class="blog"/></a>
</section>

进入自定义嵌套代码:

{{section.foo}}
{{h1}}My title {{span style=color:#F00}}is awesome{{end-span}}{{end-h1}}
{{a href=#blog}}{{img.blog src=assets/img/blog.jpg}}{{end-img}}{{end-a}}
{{end-section}}

您可以看到class属性需要位于标记名称旁边,只需用点分隔。

我对regexp表达不是很熟悉,所以找到一些东西很痛苦......

有什么想法吗?

thks:)

0 个答案:

没有答案
相关问题