Closed bergus closed 9 years ago
Thanks
This still doesn't make much sense. new RegExp("\\u004" + "A").test("u004A") === false
.
I don’t understand the confusion.
RegExp('\\u004' + 'A').test('J');
// → true
RegExp('\\u004' + 'A', 'u').test('J');
// → true
This patch makes sure that:
RegExp('\\u004' + RegExp.escape('A')).test('J');
// → false
RegExp('\\u004' + RegExp.escape('A'), 'u').test('J');
// → throws
If it's required (or desirable) to prevent RegExp('\\u004' + RegExp.escape('A'))
expanding to RegExp('\\u004A')
, then you probably also want to make sure RegExp('\\c' + RegExp.escape('G'))
does not expand to RegExp('\\cG')
. That means not only 0-9A-Fa-f
, but actually 0-9A-Za-z_
needs to be escaped.
@anba Can you add that to #29, please? I didn't think /\c/
alone was valid, but it seems to compile indeed (though I don't see what it matches).
@bergus Added a comment to the other issue.
Follow up to #34. @anba I knew it, damn.