Finding an open and closing tag in Regexp

Posted by Rixius on Stack Overflow See other posts from Stack Overflow or by Rixius
Published on 2010-05-17T02:38:08Z Indexed on 2010/05/17 2:40 UTC
Read the original article Hit count: 279

Filed under:
|
|

Is there a way to find custom tags in regexp I.e. match

{a}sometext{/a}  

As well as

{c=#fff}sometext{/c}  

So that it finds the entire block of inner content? The problem is the sometext could have another tag as in:

{a=http://www.google.com}{b}Hello, world{/b}{/a}  

The only solutions I can come up with would match from {a... to .../b} when I want {a... to .../a} is there a single regexp solution, or would it be best to match the start, and then use another method to find the end from the back up, and grab it out that way? I'm using PHP 5.2 so I have all the options that entails.

© Stack Overflow or respective owner

Related posts about regex

Related posts about php