Closed RunDevelopment closed 4 years ago
Thank you for your report.
But this is intended -- according to the spec.
\c
is not an escape sequence: https://tc39.es/ecma262/#prod-annexB-SourceCharacterIdentityEscape
You can see this behavior:
~\dev\sandbox\foo [master]> node
Welcome to Node.js v12.12.0.
Type ".help" for more information.
> /^\c$/.test("\\c")
true
> /^[\c]$/.test("c")
true
> /^[\c]$/.test("\\")
true
Thank you for the response.
I assumed that it behaves like \x
and \u
but that's not the case. Very interesting!
RegExpp: v3.1.0 NodeJS: v13.12.0
The following code:
will output the following
As you can see,
\c
is parsed as a backslash character and the characterc
. This happens both inside and outside of character classes. Instead, it should be parsed as a single characterc
.