常用正则表达式,来自新浪微博的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
});

转载于:https://www.cnblogs.com/liyulong1982/archive/2013/01/30/2882556.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值