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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -