in reply to Regex weirdness?

[^\2] does not match everything except what was captured by the second capturing group. Instead, it matches everything except the second ASCII character. What you need to use is a negative lookahead combined with an any-match: (?!\2)(?s:.).

Note that even with this fix your pattern doesn't handle escaped escape characters.

ihb

See perltoc if you don't know which perldoc to read!