javascript - var str= 'asd,asd,12,321,,123,6,yrtv,x,z'; How many methods are there to obtain the numbers?
大家讲道理
大家讲道理 2017-06-28 09:26:30
0
2
1057

var str= 'asd,asd,12,321,,123,6,yrtv,x,z'; How many ways are there to get the numbers?

var str= 'asd,asd,12,321,,123,6,yrtv,x,z';

A regular method, use split to split into arrays. Is it possible to use the filter method of the array? Please solve it and write it down one by one. Thank you.
Example 1:

var reg = /\d+/g;
var str = "ss12345rr3432re232";
var ms = str.match(reg)
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
扔个三星炸死你

str.split(",").filter(a => a !== "" && !isNaN(+a))

曾经蜡笔没有小新
// 如果只要数字不分组的话,这个方法最简单
str.replace(/[^\d]/gi, '')
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template