JSFiddle - React, Tailwind, and code Playground
by Sahin Deniz
JavaScript
let list = `16053749
tr16053758
ert16053743
t16053750
z16053759
r16053744
16053751
16053872
16053879
16053886
16053873
16053880
16053887
16053874
16054029
16054037
16054023
16054030`;
let idList = [16053749, 16053758, 16053743, 16053750, 16053759, 16053744, 16053751, 16053872, 16053879, 16053886, 16053873, 16053880, 16053887, 16053874, 16054029, 16054037, 16054023, 16054030];
//let a = list.replace(/((?:.*?[-/])(?=\d))|(?:[?/].*)|(?:[a-z]{1,})/gi, "").split(/\r\n|\n/g);
console.log(new RegExp(`((?:\\b|[a-z]{1,})+(?:${idList.join("|")})\\b)`, "g"));
list = list.replace(new RegExp(`((?:\\b|[a-z]{1,})+${idList.join("|")}\\b)`, "g"), (a,
b) => {
console.log(a,b);
return `<span class="sg-text--background-">${a}</span>`
})
console.log(list);