Regex for capturing a character between a group but ignoring the ones in a nested group.

Posted by peroyomas on Stack Overflow See other posts from Stack Overflow or by peroyomas
Published on 2010-04-08T03:35:43Z Indexed on 2010/04/08 3:43 UTC
Read the original article Hit count: 274

Filed under:
|

This is for make something similar to "templates" in MediaWiki with PHP in order to make the parameters between nested templates work.

Is possible with a regex to capture all occurrences of a character between braces but ignoring occurrences of it if it occurs in a nested group of braces?

| {{ | {{ | }} | | }} |

Highlighted:

| {{ *|* {{ | }} *|* *|* }} |

© Stack Overflow or respective owner

Related posts about regex

Related posts about php