精慕HU
不是很清楚你的具体需求,直接提取不就是了const str = "...![a](b)...";const result = str.match(/!\[(.*?)\]\((.*?)\)/);console.log(result); // ["![a](b)", "a", "b"]获取多个的话可以用execconst str = "...![a](b)...![c](d)...";const pattern = /!\[(.*?)\]\((.*?)\)/mg;const result = [];let matcher;while ((matcher = pattern.exec(str)) !== null) { result.push({ alt: matcher[1], url: matcher[2] });}console.log(result); // [{ alt: 'a', url: 'b' }, { alt: 'c', url: 'd' }]