Implementation CodeAs shown below, the test was normal at first (and then encountered a problem). First, let's look at the initial code.
Copy codeThe Code is as follows: var docs = Document. Body. innerhtml;
VaR links = docs. Match (/ed2k. * \ | \ // gi); // note that the dot (.) symbol is used to match any character.
Document. Body. innerhtml = "";
For (VAR link in links) {<br>
Document. Body. innerhtml + = Links [LINK] + "<br/>"
}
The above code is normal at first. In the next test, it is found that if the address contains full-angle characters, the matching will fail. Use the following method:Copy codeThe Code is as follows: var docs = Document. Body. innerhtml;
VaR links = docs. Match (/ed2k [\ s] *? \ | \ // Gi); // note that [\ s]
Document. Body. innerhtml = "";
For (VAR link in links ){
Document. Body. innerhtml + = Links [LINK] + "<br/>"
}
Conclusion, point (.) the symbol still has limitations when matching any character. The specific rules are unknown and can be replaced by [\ s] for the moment, similarly, either [\ D] or [\ W] can be used.