Including a hyphen in a regex character bracket?

前端 未结 6 501
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 03:34
$.validator.addMethod(\'AZ09_\', function (value) { 
    return /^[a-zA-Z0-9.-_]+$/.test(value); 
}, \'Only letters, numbers, and _-. are allowed\');
6条回答
  •  再見小時候
    2020-11-22 04:08

    \- should work to escape the - in the character range. Can you quote what you tested when it didn't seem to? Because it seems to work: http://jsbin.com/odita3

提交回复
热议问题