<body>
<input type="text" id="txtInput" /> <input type="button" onclick="check()" value="check" />
<br /><br /> <hr />
<script type="text/javascript" >
function check(){
var re=/(1)((2)3)/g;
var arr;
var src =document.getElementById("txtInput").value ;
document.write(src + "<br>");
while ((arr = re.exec(src)) != null)
// debugger; //arr返回一个数组.length为(组)的个数,
if(arr!=null){
document.write('test:'+arr[1]+',idx:'+ arr.index + ",LastIdx:" + arr.lastIndex + ",Value:" + arr+ "<br>");
}else {alert('null');}
}
/*
d123d123
test:1,idx:1,LastIdx:4,Value:123,1,23,2
test:1,idx:5,LastIdx:8,Value:123,1,23,2
*/
</script>
</body>
</html>