我有一些文字,包括文章的数量;我需要得到这些数字的数组(包括文章),然后是“标记词”。fe 在文本中:
《123456/9902/001 一二三手 123456/9902/002 胖子抽签 123456/9902/003 五六 123456/9902/004 七十黄油》
我为“标记词”= [hand,ten] 生成的数组将是:
【“123456/9902/001一二三手”、“123456/9902/004七十黄油”】
我的代码找到了一些东西,但它工作错了,正确的正则表达式是什么?
let markers = ["hand", "ten"],
fin = [];
let num = "(\\d{6}\/\\d{4}\/\\d{3}).*?";
markers.forEach(item => {
let reg = new RegExp(num + item, 'gmi');
found = text.match(reg);
found.forEach(item => fin.push(item));
if (result) {
console.log(`for ${item} : ${found.length}`);
console.log(found);
} else {
(console.log('Nothing'))
}
})
console.log(fin)