Revenge of the greedy RegEx
Naturally, when I get my text parsing right for
the forums and release it, I realize that my test coverage wasn't as good as I had hoped. I've got a spot of code that looks for pseudo-code quote tags for conversion to an HTML blockquote. The expression looks like this:
(\[quote\])(.*)(\[/quote\]) Works like a champ... sort of. The middle group in the Match object (match.Groups[2]) then gets parsed to look for nested quotes. This works well to.
The problem is that it counts this as one entire match:
[quote]quote 1[/quote][quote]quote 2[/quote] Where I'm troubled is that I'm not sure which group I should be altering. The middle "meat" of the quote I need to access via the Groups collection so I can parse for nested quotes, and every attempt I've made to alter this breaks the proper nesting.
I hate it that this one area causes me so much grief. I'm not brilliant, but I would think I'd be smart enough to keep this from eluding me! Help is appreciated.