ToB企服应用市场:ToB评测及商务社交产业平台
标题:
js 实现类似php preg_match_all 函数的函数封装
[打印本页]
作者:
怀念夏天
时间:
2022-8-9 14:39
标题:
js 实现类似php preg_match_all 函数的函数封装
function matchAll (data, exp) {
var regex = exp;
var Regex = new RegExp(regex, 'mg');
var Matches = data.match(Regex);
matchesArray = new Array();
for (var i in Matches) {
ngRegex = new RegExp(regex);
ngMatches = Matches[i].match(ngRegex);
matchesArray.push(ngMatches);
}
return matchesArray;
}
复制代码
//将所有的外连转换成内链跳转
var exp = /\d+/;
var output = matchAll('32323adsdsa32232adsds2332sdds', exp);
console.log(output);
复制代码
参考:
https://www.zhangwenbing.com/blog/nodejs/SytJ9s1WQ
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/)
Powered by Discuz! X3.4