-1

ブロック div があり、「a href onclick」のような不明な数のリンクがあります。複数のリンクがある場合は、コンマとスペースで区切られます。

var reg = /<div class="labeled fl_l"><a href="[^"]*" onclick="[^"]*">(.+?)<\/a>(, <a href="[^"]*" onclick="[^"]*">(.+?)<\/a>{1,})?<\/div>/mg;
var arr;
while ((arr = reg.exec(data)) != null) {
            console.log(arr[0]); //contains the entire text (because it is java script)
    console.log(arr[1]); //contains the name of the first link
    console.log(arr[2]); //contains the following "a href" entirely (if I will point out (?: x, <a... /a>), then the nested brackets will not work)
    console.log(arr[3]); //contains the name of the second link, **and then all of the code**
}

}

([^ <] *)の代わりにそれを使うべきだと思いますが(. +?)、それではまったく機能しません。

4

1 に答える 1