I'm looking for some help with a regex to be used in an iPhone application.
I'm using NSRegularExpression.
NSString *string = @"[quote author=iffets12345 link=topic=36426.msg388088#msg388088 date=1294820175][quote author=fuzzylogic link=topic=36426.msg387976#msg387976 date=1294802623]Although it wouldn't come up too often in an English essay: MUM not mom!!!![/quote]Haha, EXACTLY![/quote]";
I have this string which is just BBCode for a forum post. In this case, a quote inside a quote.
NSRegularExpression *quoteRegex = [NSRegularExpression regularExpressionWithPattern:@"\\[quote author=(.*?) .*?\\](.*?)\\[\\/quote\\]"
options:NSRegularExpressionCaseInsensitive
error:&error];
And that's the regex I'm using to parse it.
It works fine on just normal BBCode without nested quotes. But when the quotes are nested this regex doesn't work as I would like it to.
When running the regex on this particular string it would return something like this:
"[quote author=iffets12345 link=topic=36426.msg388088#msg388088 date=1294820175][quote author=fuzzylogic link=topic=36426.msg387976#msg387976 date=1294802623]Although it wouldn't come up too often in an English essay: MUM not mom!!!![/quote]
It is incorrectly matching the opening and closing quote tags.
Can anyone see what I'm missing? Thanks.