JavaScript Regular Example

Source: Internet
Author: User

See if the page has a JS
var slist=document.getelementsbytagname (' script ') | | [];
var reg=/jquery\.min\.js/i;
for (Var i=0;i<slist.length;i++) {
if (Reg.test (SLIST[I].SRC)) {
Return
}
}
The simplest regular expression that will match the string "JQuery.min.js"
"I" means no case,I flag (i is ignorecase or case-insensitive)
Document. Url.match (/[^:]+/)
[] matches any character in the specified range, in [] it represents a negative character set,
Matches any character not in the specified range, where all characters except ': ' are matched
The + sign indicates that the character must appear at least 1 times
The match () method retrieves the specified value within a string, or finds a match for one or more regular expressions.
Stringobject.match (Searchvalue) stringobject.match (regexp)
(function() {        console.info (document. URL)        var r =document. Url.match (/[^:]+/);        Console.info (R);         var rs =document. Url.match (/[^:]+/g);        Console.info (RS);    }) ();
http://localhost:63342/cquery/jsfunctiontest/match.html["http"]["http", "// LocalHost "," 63342/cquery/jsfunctiontest/match.html "]

JavaScript Regular Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.