mathiasbynens/regexpu

Support for back-references

anba opened this issue · 1 comments

anba commented

/(s)\1/ui is currently transformed to /([s\u017F])\x01/i.

  1. Back references should probably not be transformed to hexadecimal escapes
  2. Canonicalizing the back reference's content is tricky, I'm not sure how this feature can be supported without canonicalizing the input string first, e.g. in /(s)\1/ui.test("s\u017f") == true.

Good catch – thanks!

(1) is a bug in regjsparser, which regexpu depends on. I’ve reported it and and will try to get it fixed as soon as possible.

As for (2), I’d rather not transpile strings too (especially since it could only ever work reliably for literals). I’ve managed to avoid this for /iu regular expressions without back-references. I’m afraid you’re right that it cannot be done in these cases, though. :(

Once (1) is resolved, I’ll add a note to the README saying regexpu doesn’t support canonicalizing the contents of back-references in regular expressions with both the i and u flag set, since that would require transpiling/wrapping strings.