zoukankan      html  css  js  c++  java
  • 常用正则表达式,来自新浪微博的js

    STK.register("common.setting.rule", function(a) {
    var b = {};
    b.isEmpty = function(a) {
    return /^\s*$/g.test(a.replace(/^\s+|\s+$/g, ""))
    };
    b.isNumber = function(a) {
    return /^[+\-]?\d+(\.\d+)?$/.test(a)
    };
    b.isName = function(a) {
    return /^[0-9a-zA-Z\u4e00-\u9fa5_-]+$/.test(a)
    };
    b.isCompany = function(a) {
    return /^[0-9a-zA-Z\u4e00-\u9fa5\uff08\uff09()]+$/.test(a)
    };
    b.isChinese = function(a) {
    return /[\u4e00-\u9fa5]+$/.test(a)
    };
    b.isCName = function(a) {
    return /^[\u4e00-\u9fa5]+[\u00b7\.]?[\u4e00-\u9fa5]+$/.test(a)
    };
    b.isEmail = function(a) {
    if (!/^[0-9a-z_][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\.){1,4}[a-z]{2,4}$/.test(a))
    return !1;
    if (a && a != "" && a.indexOf("@") != -1) {
    var b = a.indexOf("@"), c = a.substring(0, b);
    return c.length > 64 || a.length > 256 ? !1 : !0
    }
    return !1
    };
    b.isEmailName = function(a) {
    return /^[0-9a-z_][_.0-9a-z-]{0,31}$/.test(a)
    };
    b.isIDNumber = function(a) {
    return /^[\d]{15}$/.test(a) || /^[\d]{17}([Xx\d]{1}$)$/.test(a)
    };
    b.isMobile = function(a) {
    return /^1[3|4|5|8][0-9]{9}$/.test(a)
    };
    b.isWeird = function(a) {
    return !/^[a-zA-Z0-9\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b\uFF01\u201c\u201d\u2018\u2019\u300e\u300f\u300c\u300d\uFF09\uFF08\.\_\-\?\~\!\@\#\$\%\^\&\*\\\+\`\=\[\]\(\)\{\}\|\;\'\:\"\,\/\<\>]+$/i.test(a)
    };
    b.isPassportID = function(a) {
    return /^[a-zA-Z0-9]{8,20}$/.test(a)
    };
    b.isAbroadName = function(a) {
    return /^[a-zA-Z\u4e00-\u9fa5]+([\u00b7\.\- ]?[a-zA-Z\u4e00-\u9fa5]+)*$/.test(a)
    };
    b.lenLimit = function(b, c, d) {
    var e = a.bLength(b);
    return !(e < c || e > d)
    };
    b.isUrl = function(a) {
    return /^http:\/\/([\w-]+(\.[\w-]+)+(\/[\w- .\/\?%@&+=\u4e00-\u9fa5]*)?)?$/i.test(a)
    };
    b.turnBoolean = function(a) {
    switch (typeof a) {
    case "boolean":
    return a;
    case "number":
    return !!a;
    case "string":
    return a == "true" || a == "1"
    }
    };
    b.reNullChar = function(a) {
    return a.replace(/^\s+|\s+$/g, "")
    };
    return b
    });

  • 相关阅读:
    iOS 饼状图
    objective-c 中随机数的用法 (3种:arc4random() 、random()、CCRANDOM_0_1() )
    倒计时获取验证码、事件代码
    iOS 技能集结号
    自定义控件:半透明控件
    c# string
    软考题
    php简单实例
    .net 线程池的简单应用
    c# 堆栈四则运算
  • 原文地址:https://www.cnblogs.com/liyulong1982/p/2882556.html
Copyright © 2011-2022 走看看