简体   繁体   中英

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;
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM