L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<script type="text/javascript">
<!--
var reg1 = /id=[0-9]+/gi;
// ^ 表明起始位置,$ 表明结束位置
var reg2 = /^id=[0-9]+$/gi;
var s1 = "id=123";
var s2 = "<input id=123 />";
alert(reg1.test(s1)); // true
alert(reg1.test(s2)); // truealert(reg2.test(s1)); // true
alert(reg2.test(s2)); // false
//-->
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<script type="text/javascript">
<!--
var reg1 = /id=[0-9]+/gi;
// ^ 表明起始位置,$ 表明结束位置
var reg2 = /^id=[0-9]+$/gi;
var s1 = "id=123";
var s2 = "<input id=123 />";
alert(reg1.test(s1)); // true
alert(reg1.test(s2)); // truealert(reg2.test(s1)); // true
alert(reg2.test(s2)); // false
//-->
</script>
</body>
</html>
str = 'your id=123'则:/id=[0-9]+/gi 可以匹配str.
/^id=[0-9]+$/不行str = 'id=123'则:/id=[0-9]+/gi 可以匹配str.
/^id=[0-9]+$/ 也可以