zoukankan      html  css  js  c++  java
  • 正则

    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 有数字大小限制
  • 相关阅读:
    7. Reverse Integer
    2. Add Two Numbers
    1039. 顺序存储二叉树
    Codeforces 535D
    Codeforces 385D
    URAL
    URAL
    Codeforces Round #428 (Div. 2)
    鹰蛋坚硬度实验
    Codeforces Round #392 (Div. 2)-D. Ability To Convert
  • 原文地址:https://www.cnblogs.com/anyaran/p/4885961.html
Copyright © 2011-2022 走看看