我需要测试一个可能包含数字、字母、破折号、正斜杠和其他字形的字符串。只允许使用数字、破折号和正斜杠。尝试了几次,但我一直弄错正则表达式语法。
基本上:
var str = '03/02/2013'; //03-02-2013 is also acceptable
if(str has letters in it){
console.log('incorrect formatting');
}else{
//string is made up of only numbers, dashes or forward slashes
console.log('okay');
}