您的位置:首页 > Web前端 > JavaScript

javascript:正则表达式对象

2012-06-08 23:48 274 查看
<html>
<head>
<title>1</title>
<style type='text/css'>
#box{
width:300px;
height:200px;
border:dashed 1px green;
}
</style>
</head>
<body>
<div id='box'>
</div>
<script language='javascript'>
var exp=/\w(\d+)/g;//加g返回156 3;不加则返回156 156
var str="zhangsan156lisi3wangwu";
//var arr=str.split(exp);
var arr=exp.exec(str);
document.write(arr+'  ');
arr=exp.exec(str);
document.write(arr);

</script>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: