Amit Naik
Amit Naik

Reputation: 43

jslint showing Unescaped '-' but my regex is right

I need to check if string contains numbers, "." or "_" or "-". But jslint is showing below error:

Lint at line 63160 character 53: Unescaped '-'

Below is my code.

if ( value.match( /^[0-9._-]+$/ )) {
    return true;
}

Upvotes: 1

Views: 375

Answers (1)

Amit Naik
Amit Naik

Reputation: 43

Just read the jslint docs and got it working! Also there is a bug reported in jshint here

Below is the fix

if(value.match(/^[0-9\-]+$/i))

Thank you for your help.

Upvotes: 2

Related Questions