求一正则表达式,很简单的
1/329749/4 7437678(1)
1 integer + “/” + 6 integers + “/” + 1 integer
7 integers + “(” + 1 integer + “)”
求两者都符合的正则表达式
------解决方案--------------------/(\d\/\d{6}\/\d)|(\d{7}\(\d\))/
------解决方案--------------------稍微改下就行
var reg2=/(^\d\/\d{6}\/\d$)|(^\d{7}\(\d\)$)/g
------解决方案--------------------1.正则加入判断
var pattern =/(^\s+?\d\/\d{6}\/\d\s+?$)|(^\s+?\d{7}\(\d\)\s+?$)/g;
2.先删除字符前后空格再匹配
<script>
function trims(str)
{ //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, " ");
}
str = ' 1/329749/4 ';
var pattern =/(^\d\/\d{6}\/\d$)|(^\d{7}\(\d\)$)/g;
if(trims(str).match(pattern)) alert( 'pass ');
</script>