我想转换它:(来自Wordpress)
[caption id="attachment_5433" align="aligncenter" width="413"]
<a href="http://baicadicungnamthang.net/uploads/2012/02/NSUT-Tuyet-Thanh.jpg"><img class=" wp-image-5433" title="NSUT-Tuyet-Thanh" src="http://baicadicungnamthang.net/uploads/2012/02/NSUT-Tuyet-Thanh.jpg" alt="NSƯT Tuyết Thanh" width="413" height="551"></a>NSƯT Tuyết Thanh
[/caption]
到此:(html5)
<figure>
<a href="http://baicadicungnamthang.net/uploads/2012/02/NSUT-Tuyet-Thanh.jpg"><img class=" wp-image-5433" title="NSUT-Tuyet-Thanh" src="http://baicadicungnamthang.net/uploads/2012/02/NSUT-Tuyet-Thanh.jpg" alt="NSƯT Tuyết Thanh" width="413" height="551"></a>
<figcaption>NSUT Tuyết Thanh</figcaption>
</figure>
如何通过PHP或C#来实现?
答案 0 :(得分:0)
试试这个:
$subject = preg_replace(
'/\[caption[\s]{0,}(.*?)\][\s]{0,}(<a[\s]{0,}.*?<\/a>)[\s]{0,}(.*?)\[\/caption\]/ims',
'<figure $1> $2 <figcaption>$3</figcaption> </figure>',
$subject);
$ subject的实际字符串[caption]到[/ caption]