in reply to Regex weirdness?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex weirdness?
by Pic (Scribe) on Mar 15, 2005 at 01:42 UTC |