I have the following regular expresssion
/\<oauth_token\>([^\<]*)\<\/oauth_token\>/
I am seeing jslint violations for unescaped < characters, but can't work out why. Can anyone enlighten me please?
This regular expression is being assigned to a variable and is being used throughout the file. It is in a nodejs module.
This is a hack to get round a non-standards conformant OAUth response, which will be fixed at some point in the future. I do not want to bring in an XML parser as an extra dependency to solve the problem.
I am seeing this violation both with JSHint and node-jslint.
You can see the full source code for the file on github The exact output from JSHint is as follows:
lib/oauth-helper.js: line 5, col 21, Unexpected escaped character '<' in regular expression.
lib/oauth-helper.js: line 5, col 39, Unexpected escaped character '<' in regular expression.
lib/oauth-helper.js: line 5, col 44, Unexpected escaped character '<' in regular expression.
lib/oauth-helper.js: line 6, col 22, Unexpected escaped character '<' in regular expression.
lib/oauth-helper.js: line 6, col 47, Unexpected escaped character '<' in regular expression.
lib/oauth-helper.js: line 6, col 52, Unexpected escaped character '<' in regular expression.
There's no need to escape the "<" character in a regular expression. That's what JSLint is telling you - that the backslashes before your "<" characters in the pattern are unnecessary.
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