I think the problem is in [^\2] - you can't interpolate matches into character classes this way. One way to get around that is to use a negative lookeahead instead.
Also, this will have problems with 'Don\'t do this', since the backslash will be matched by the character class, which means the escaped quote ends up terminating the string. Check for backslashes first to avoid that:
m{( [^"']+ | (["']) (?: \\ . | (?!\2) . )* \2 )}xgs
Hugo
In reply to Re: Regex weirdness?
by hv
in thread Regex weirdness?
by Pic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |