为你而来

javascript:正则表达式对象

 1 <html>
 2 <head>
 3 <title>1</title>
 4 <style type='text/css'>
 5 #box{
 6     width:300px;
 7     height:200px;
 8     border:dashed 1px green;
 9 }
10 </style>
11 </head>
12 <body>
13 <div id='box'>
14 </div>
15 <script language='javascript'>
16     var exp=/\w(\d+)/g;//加g返回156 3;不加则返回156 156
17     var str="zhangsan156lisi3wangwu";
18     //var arr=str.split(exp);
19     var arr=exp.exec(str);
20     document.write(arr+'&nbsp;&nbsp;');
21     arr=exp.exec(str);
22     document.write(arr);
23 
24 </script>
25 
26 </body>
27 </html>

 

posted on 2012-06-08 23:48  为你而来  阅读(171)  评论(0编辑  收藏  举报

导航