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.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn