console.log('\d' === 'd'); // true
Character 'd' is not a special character, why javascript want to slice the escape notation. It's better to keep the escape notation in my view.
When I want to fully match string-'\d' using regular expression, it just impossible! Taking the following code as an example.
console.log(RE.test('\d')); // it should log true
console.log(RE.test('d')); // it should log false
Unfortunately, you just cannot figure out a regular expression pattern.
You have no reason to escape d in a string and JavaScript ignores it. If you need \d you need to escape the escape character: \\d.
See also Why do linters pick on useless escape character?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With