正则表达式匹配以下字符串

时间:2017-11-30 18:14:40

标签: javascript regex

大家好,我有以下代码:

<!--
            <li class="dropdown">
                <a href="#/score-board">Score Board</a>
                <a href="#/score-lol">Score lol</a>
                <a href="#/score-abcd">Score lolk</a>

            </li>
            -->

我需要有一个正则表达式

我试过了:

&#13;
&#13;
const regex = /(#.score([\s\S]*?).b([\s\S]*.?))/g;
const str = `<!--
            <li class="dropdown">
                <a href="#/score-board">Score Board</a>
                <a href="#/score-abc">Score Board</a>
                <a href="#/score-lol">Score Board</a>
            </li>
            -->`;
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}`);
    });
}
&#13;
&#13;
&#13;

我希望得到以下结果 的#/分板

有人可以帮助我吗?

注意!重要的是它取得&#34; &#34;

之间的所有内容

提前谢谢

0 个答案:

没有答案