Recursive regex pattern replace
I have recently started working with regex and it is nice/useful, but still confusing.
I've accomplished most of what I want, but now I have a situation where I need a bbcode tag to be able to exist within itself then the proper html to be generated.
In other words:
<tag><tag></tag></tag>
There are a lot of complications that can be generated from this, and I know that recursive regex is possible, but I have no idea where to write it.
Code:
//I want this:
[tag=value]text [tag=value]text[/tag] text[/tag]
//To become:
<tag property="value">text <tag property="value">text</tag> text</tag>
And this needs to go many layers deep (possibly) so a recursive function is best.
From an example, I can work out the details. A link to a tutorial is fine as well, as long as it has this exact setup (varied tag names of course), since I'm not sure I can adapt it with my current knowledge of regex from another scenario.
BTW, I do want it to verify that this is valid so it doesn't generate unclosed tags (and invalidate the page), so a simple search and replace won't be enough I don't think.
Thanks!