xregexp icon indicating copy to clipboard operation
xregexp copied to clipboard

Make it an error to escape any character that doesn't need to be escaped

Open slevithan opened this issue 8 years ago • 0 comments

Following ES6, make the token that blocks invalid metasequences (here) even stricter by also making it an error to escape punctuation, etc. in cases where the escaped character is not special on its own. In ES6 with flag u, the only characters interpreted as themselves when escaped are ^ $ \ . * + ? ( ) [ ] { } | (and presumably a hyphen in character classes).

Need to ensure this accounts for characters that are special only with certain XRegExp flags, e.g. escaping whitespace with flag x. This is probably handled automatically by XRegExp applying tokens in reverse insertion order.

While at it, should probably also disallow \b within character classes since \b for the backspace control character is a super minor convenience and creates confusion given the difference in meaning of \b outside character classes.

slevithan avatar Apr 17 '17 07:04 slevithan