精慕HU
不是很清楚你的具体需求,直接提取不就是了const str = "......";const result = str.match(/!\[(.*?)\]\((.*?)\)/);console.log(result); // ["", "a", "b"]获取多个的话可以用execconst str = ".........";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' }]