KL.Util = {
isEmail : function(v) {
return /^([a-zA-Z0-9_.-+])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/
.test(v);
},
isMobile : function(v) {
return /^[0]?[1][0-9]{10}$/.test(v);
},
isUrl : function(v) {
return v == "" ? true
: new RegExp(
"^https?:\/\/([\w-]+(\.[\w-]+)+(\/[\w- .\/\?%@&+=\u4e00-\u9fa5]*)?)?$")
.test(v);
},
// 鑾峰彇瀛楃�涓蹭腑鏂囬暱搴�
cnStrlen : function(str) {
var thelen = str.replace(/[^x00-xff]/g, "**").length / 2;
return parseInt(thelen) == thelen ? thelen : parseInt(thelen + 0.5);
},
reload: function (tohome) {
if (tohome === true) {
window.location.href = this.sitehost;
} else {
window.location.reload();
}
}
};
去掉字符串前面的0
var numString = "000123456789987654321";
alert(numString.replace(/^0+/g, '')); //若是用 parseInt 有数字大小限制