Js获取字符串中的所有数字超强版

const str = '1,2 346 4,5 ,   89,8, ,9, , , , , ,   。34,67,33   。 45、 3454;3434。‘’ @*3   456  ]     345   p  rFWOGLEGW888 [AT[WOE4KT4T;#%#¥……& 66i66';
const regex = /\d+/g;  // 匹配所有数字,g表示全局匹配
const matches = str.match(regex); //获取所有匹配项
console.log(matches)

猜你喜欢

转载自blog.csdn.net/qq_39548550/article/details/130272352
今日推荐