我不会删除它,
我尝试了这个How do I match any character across multiple lines in a regular expression?。但没有用。
<span> powered by </span>
<a
href="http://keystonejs.com"
target="_blank"
className={css(classes.link)}
tabIndex="-1"
>
KeystoneJS
</a>
const string = `
tabIndex="-1"
className={css(classes.link)}
>
{brand + (appversion ? (' ' + appversion) : '')}
</a>
<span> powered by </span>
<a
href="http://keystonejs.com"
target="_blank"
className={css(classes.link)}
tabIndex="-1"
>
KeystoneJS
</a>
<span> version {version}.</span>
{this.renderUser()}
`;
console.log(string.match(/<span>\spowered(.*)<\/a>/gmi));
答案 0 :(得分:-1)
这有效
string.match(/<span>\spowered(.|\n)*<\/a>/gim)
您的代码无效,因为。与新行不匹配