Regular URL Matching

Source: Internet
Author: User

Today, for the regular URL match.

Example: url = "https://v5.lairen.com/activity?id=862&code=ab9a61823398273b7b036fd9ed1a885e"?

The first thing to parse is the protocol and domain name

Currently, there are three types of agreements: Http|ftp|https

and domain names are generally non-empty strings

var reg =/(HTTP|FTP|HTTPS): \/\/([^/\r\n]+)/(\s+)/;

Get the results returned:

Remove returned results

? Then parse the following

"Activity?id=862&code=ab9a61823398273b7b036fd9ed1a885e"

Use the Regular:

/(\s+) (? =\?) \? (\s+)/g

You can divide the above string into two parts

Activity and ID=862&CODE=AB9A61823398273B7B036FD9ED1A885E

Use

/(\s+) = (\s+) & (\s+) = (\s+)/g;

Get results:

?

Regular URL Matching

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.