Fix for escaping backrefs inside regexps. Fixes #646.