案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<body>
3
4
<script type="text/javascript">
5
var str = "The rain in Spain stays mainly in the plain";
6
var patt1 = new RegExp("ain", "g");
7
8
for(i = 0; i < 4; i++) 
9
  {
10
  patt1.test(str)
11
  document.write("ain found. index now at: " + patt1.lastIndex);
12
  document.write("<br />");
13
  }
14
</script>
15
16
</body>
17
</html>
18