常见的正则表达式

前端之家收集整理的这篇文章主要介绍了常见的正则表达式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
-  case 'required': pattern = /\S+/i;break;
-             case 'name': pattern = /^[a-zA-Z_][a-zA-Z0-9_-]{5,}$/i;break;
-             case 'email': pattern = /^\w+([-+.]\w+)*@\w+([-.]\w+)+$/i;break;
-             case 'qq':  pattern = /^[1-9][0-9]{4,}$/i;break;
-             case 'id': pattern = /^\d{15}(\d{2}[0-9x])?$/i;break;
-             case 'ip': pattern = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i;break;
-             case 'zip': pattern = /^\d{6}$/i;break;
-             case 'phone': pattern = /^((\d{3,4})|\d{3,4}-)?\d{7,8}(-\d{3})*$/i;break;
-             case 'mobi': pattern = /^1[3-9]\d{9}$/i;break;
-             case 'url': pattern = /^[a-zA-z]+:\/\/(\w+(-\w+)*)(\.(\w+(-\w+)*))+(\/?\S*)?$/i;break;
-             case 'date': pattern = /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/i;break;
-             case 'datetime': pattern = /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29) (?:(?:[0-1][0-9])|(?:2[0-3])):(?:[0-5][0-9]):(?:[0-5][0-9])$/i;break;
-             case 'int': pattern = /^\d+$/i;break;
-             case 'float': pattern = /^(-)?\d+\.?\d*$/i;break;
-             default: pattern = new RegExp('^'+pattern+'$','i')
原文链接:/regex/358376.html

猜你在找的正则表达式相关文章