The implementation code is as follows. The test was normal at first (later encountered problems), let’s first look at the initial code
var docs = document.body.innerHTML;
var links =docs.match(/ed2k.*|//gi);//Note that the dot (.) symbol is used here to match any Characters
document.body.innerHTML = "";
for( var link in links){
document.body.innerHTML = links[link] "
"
}
The above code worked fine at first, but in subsequent tests it was found that if there are full-width characters in the eDonkey address, the match will fail. Then use the following writing method:
var docs = document.body. innerHTML;
var links =docs.match(/ed2k[sS]*?|//gi);//Note here [sS]
document.body.innerHTML = "";
for( var link in links){
document.body.innerHTML = links[link] "
"
}
Conclusion, the dot (.) symbol matches any character There are still limitations, and the specific rules are unknown. For the time being, [sS] can be used instead. Similarly, [dD] or [wW] can also be used.