`

javascript (眼泪一)

 
阅读更多

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<script type="text/javascript">
	// 元字符  <<[ ] \ ^ $ . | ? * + ( )>>
	// <<1\+1=2>> 匹配 1+1=2
	//<<\t>>	代表Tab
	//<<\r>>	代表回车
	//<<\n>>	代表换行符
var str1 = "Like you do not need to reason.";
	function isDigit(s){  
		 var patrn=/^[0-9]{1,20}$/;  
		 if (!patrn.exec(s)) return false 
		 return true 
	}  
	//alert(isDigit(12232323232+"000"));

	//(jQuery('#blogTitleTex').val()).replace(/(^\s*)|(\s*$)/g, "");
	function re(s){
		//所有空格
		//s = s.replace(/\t/g,"");
		s = s.replace(/^\t*/,"");
		return s;
	}	
	//alert(re("		空   格			最	新	微	博       ")+",			空   格			最	新	微	博       ");
	
	
	var str2 =  "He captured a catfish for his catd ";

	function zfj(s){
		var patrn = /[a-zA-Z]*cat[a-zA-Z]*/;
		var s = patrn.exec(s);
		return s
	}
	//alert(zfj(str2));
	function checkNum(s){
		//var patrn = /^[0-9]{3}-[0-9]{7}$/;
		//?告诉引擎匹配前导字符0次或一次。事实上是表示前导字符是可选的。
		var patrn = /^0\d{1,2}-?\d{7,8}$/;
		var s = patrn.exec(s);
		return s;
	}
	//alert(checkNum('021-1234568'));	
	
	
	//匹配  10000-99999
	function  pNum(s){
		var patrn =  /^[1-9][0-9]{4}$/;
		var s = patrn.exec(s);
		return s;
	}

	//alert(pNum(99999));
	//匹配 100 -9999
	function p_Num(s){
		var patrn = /^[1-9][0-9]{2,3}$/;
		var s = patrn.exec(s);
		return s;
	}

	//alert(p_Num(9999));

	
	//(“\b”表示单词边界)
	function b_Num(s){
		var patrn = /\b[1-9][0-9]\d{2,3}\b/;
		var s = patrn.exec(s);
		return s;
	}
	//alert(b_Num("sdfsdf werew wewer 45 3343 343434 343"));
	
	function c_Num(s){
		var patrn = /^\d+$/;
		var s = patrn.exec(s);
		return s;
	}

	//alert(c_Num('100009'));
	
	//验证时间格式 
	function c_Time(s){
		var parnt = /^\d{2}[-/.]\d{2}[-/.]\d{4}$/;
		var s =parnt.exec(s);
		return s;
	}

	//alert(c_Time('02/10/9991'));
	//去除空  
	function rep_(s){
		s = s.replace(/(^\s*)|(\s*$)/g,"");
		return s;
	}

	//alert(rep_("    													 dfdfd     dfdfd 											      "));

	function p_(){
		var parnt = /^[a-z]+$/;
		
	}


	//验证邮箱   下划线字母数字为邮箱名称
	function c_Mail(s){
		var parnt = /^\w+@[a-z]+.[a-z]+$/gi;
		s = parnt.exec(s);
		return s;
	}

	//alert(c_Mail('30_3@qq.COM'));
	
	//匹配某个单词
	function p_21(s,s1){
		 var parnt = /\bwe\b/;
		 s = parnt.exec(s);
		 return s;
	}

	
	
</script>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics