JavaScript 正则表达式(1)

JS 正则表达式截取字符串中数组,将其放入到新的数组中,用JS 的方法如下写法

 

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>

 

<script>
var str='abc520cde213sss234-555!!!888';
var arr=[];
var news='';

for(var i = 0;i<str.length;i++){
if(!isNaN(str[i]))
{
news+=str[i];
}
else
{
if(news.length!=0)
{
arr.push(news);
news='';
}
}
};
if(news.length!=0)
{
arr.push(news);
};
alert(arr);
</script>
</body>
</html>

posted @ 2016-06-06 10:34  Jessi_JIA  阅读(100)  评论(0编辑  收藏  举报