1
以下代码正确匹配{{{
和}}}
之间的所有内容,但示例'line3'因为括号内容包含换行符。如何配合呢?Javascript匹配包括换行符在内的所有内容
const testcase = `
line1: {{{ content1 }}}
line2: {{{ content2 }}}
line3: {{{
content3
}}}
line4: {{{ content4 }}}
`;
const regex = /^(\s+)(.*?)(\{\{\{ [^]*? \}\}\})/gm;
let match;
while ((match = regex.exec(testcase)) != null) {
console.log(match);
}