zoukankan      html  css  js  c++  java
  • 正则表达式

    var defreg = {
    		"img": /(.|/)(gif|jpe?g|png)$/i,
    		"doc": /(.|/)(pdf|doc|docx|ppt|pptx)$/i,
    		"mobile": /^0?(13|15|18|14|17)[0-9]{9}$/,
    		"email": /^([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,4}$/,
    		"emailmobile": /^1d{10}$|^([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,4}$/,
    		"password": /^[^u4E00-u9FA5uF900-uFA2Du0020]{6,16}$/,
    		"loginname": /^[^u4E00-u9FA5uF900-uFA2Du0020]{26}$/,
    		//"password":/^[0-9a-zA-Z]{8,16}$/,
    		"url": /((https|http|ftp|rtsp|mms)://)?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)/g,
    		"mobilecode": /^d{6}$/,
    		"yaocode": /^d{6}$/,
    		"realname": /^[u4e00-u9fa5]{2,5}$/i,
    		"amount": /^[0-9]+([.]{1}[0-9]{1,2})?$/,
    		"vcode": /^w{4}$/
    	}
    

      

    function defcheck(str, f) {
    	if (defreg.hasOwnProperty(f) && defreg[f].test(str)) {
    		return true;
    	} else {
    		return false;
    	}
    }
    

      

  • 相关阅读:
    ES6变量的解构赋值
    ES6新增内容
    Rvalue references
    range-based for statement
    Space in Template Expression, nullptr, and auto
    Type Alias、noexcept、override、final
    Variadic Template
    =default =delete
    为什么不要特化函数模版?
    boost::noncopyable 的作用
  • 原文地址:https://www.cnblogs.com/kymming/p/6406980.html
Copyright © 2011-2022 走看看