c# - Convert caption tag to figure tag -
i want convert this: (from 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]
to this: (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>
how php or c#?
try this:
$subject = preg_replace( '/\[caption[\s]{0,}(.*?)\][\s]{0,}(<a[\s]{0,}.*?<\/a>)[\s]{0,}(.*?)\[\/caption\]/ims', '<figure $1> $2 <figcaption>$3</figcaption> </figure>', $subject);
where $subject having actual string of [caption] [/caption]
Comments
Post a Comment