I have this regex of mine that will check the string if it contains link or url (i.e. https://eslint.org/docs/rules/no-useless-escape)
. Using this regex /(\\b
\
gives error from below code in my NodeJS typescript
project, code editor is VS Code -
Code -
if (!(/^[\-0-9a-zA-Z\.\+_]+@[\-0-9a-zA-Z\.\+_]+\.[a-zA-Z]{2,}$/).test(String(req.body.email))) { ... }
Error -
Unnecessary escape character: \+. (eslintno-useless-escape)
Solution -
//eslint-disable-next-line
Final code -
//eslint-disable-next-line
if (!(/^[\-0-9a-zA-Z\.\+_]+@[\-0-9a-zA-Z\.\+_]+\.[a-zA-Z]{2,}$/).test(String(req.body.email))) { ... }