Nodejs正規表現

4865 ワード

<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>     </title>
	<script>

		var str = 'asadadfasdfsHodfasdfasdf';
		var str = 'asdfasdfasd{name}fwerwklk{age}lpild';

		var re = /hello/;
		var re = /hello/i;//      

		var re = /h...o/i;//h i        

		var re = /h.{1,}o/i;//    1 

		var re = /\{.{1,}\}/i; //         1   ,   

		var re = /\{name+\}/i;

		var re = /\{name\}/i;

		var re = /\{.*?\}/g;//*               ,?                

		var re = /\{name\}/g;//g    

		window.onload = function () {

			//1,  
			// if (re.test(str)) {
			// 	alert("yes");
			// } else {
			// 	alert("no");
			// }

			//2,  
			newStr = str.replace(re, '  ');
			alert(newStr);
		}
	</script>
</head>

<body>
</body>

</html>