Possible Duplicates:
RegEx match open tags except XHTML self-contained tags
.NET Regex balancing groups expression - matching when not balanced
For example, if I had the input:
[quote]He said: [quote]I have no idea![/quote] But I disagree![/quote] And another quote: [quote]Some other quote here.[/quote]
How can I effectively grab blocks of quotes using regular expressions without grabbing too much or too little? For example, if I use:
\[Quote\](.+)\[/Quote\]
This will grab too much (basically, the entire thing), whereas this:
\[Quote\](.+?)\[/Quote\]
will grab too little (it will only grab [quote]He said:[quote]I have no idea![/quote]
, with mismatching start/end braces).
So how can I effectively parse nested blocks of code like this using Regex?