简体   繁体   中英

Regular Expression for Alphanumeric characters and - / only

Trying to work on a regular expression in javascript that allows alphanumeric characters excludes most unique characters except - /

validateDesc: function(desc) {
    var matches = /^[a-zA-Z\d\-_.,\s]+$/;
    return matches.test(desc);
}

The one above I've tried to make only allowing alphanumeric, what do I have to add to make that happen? If anyone could give any insight on how to add other unique characters as well that would be greatly appreciated.

Regular expressions need delimiters. And be sure to include / if you want that to match.

validateDesc: function(desc) {
  var matches = /^[a-zA-Z0-9\-_., \t\/]+$/;
  return matches.test(desc);
}

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