I have some text like this:
[image]bdaypic.jpg[caption]My pic[/caption][/image]
I should get output as:
<figure><img src='bdaypic.jpg'/><figcaption>My pic</figcaption></figure>
I'm using the below code:
string = string.replaceAll("\\[image\\](.*?)\\[\\/image\\]", "<figure><img src='$1'/></figure>");
string = string.replaceAll("\\[caption\\](.*?)\\[\\/caption\\]", "<figcaption>$1</figcaption>");
but i'm getting output as
<figure><img src='bdaypic/><figcaption>My pic</figcaption>'</figure>
[caption][/caption] is optional.If it there then only it should be replaced with tag.