const regex = /(\[.*\]\(audio-1 .*\))|(\[.*\]\(img-1 .*\))|(\[\]\(video-1 .*\))/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\[.*\\]\\(audio-1 .*\\))|(\\[.*\\]\\(img-1 .*\\))|(\\[\\]\\(video-1 .*\\))', 'gm')
const str = `[null,null,null](img-1 'https://cdnapi.ergolab.cn/api/cdn/files/Teams/Picture/1/2670fff8-2119-c821-d2e6-3a04b72ac556/jsjuHxumPt4yKPRtVfR.png')
[null,null,null](img-1 'https://cdnapi.ergolab.cn/api/cdn/files/Teams/Picture/0/2670fff8-2119-c821-d2e6-3a04b72ac556/jsjuHxumPt4yLavx4gv.png')
[null,null,null](img-1 'https://cdnapi.ergolab.cn/api/cdn/files/MaterialLibrary/Picture/0/3761f21b-3016-dadd-6198-3a0569770f55/jsjuHxukkZDtF879nQB.jpg')
[](audio-1 'https://cdnapi.ergolab.cn/api/cdn/files/Teams/Audio/0/2670fff8-2119-c821-d2e6-3a04b72ac556/jsjuHxumPt4zfnkYB6m.ogg')
[](audio-1 'https://cdnapi.ergolab.cn/api/cdn/files/MaterialLibrary/Audio/0/44b29ef1-e567-e1a4-49c6-3a0545afd2f4/jsjuHidHpFagk8AbHt7.mp3')
[](video-1 'https://cdnapi.ergolab.cn/api/cdn/files/Teams/Video/0/2670fff8-2119-c821-d2e6-3a04b72ac556/jsjuHxumPt4zfnoXzSB.ogg')
[](video-1 'https://cdnapi.ergolab.cn/api/cdn/files/MaterialLibrary/Video/0/ac35f3ad-4cbb-da07-e510-39fd24ba71b5/jseEvLjEA4JXbybZQse.mp4')`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions