Regular expressions match domain names, URLs, URLs

Source: Internet
Author: User

DNS stipulates that the names in the domain name are composed of English letters and numbers, each marking no more than 63 characters, and is not case sensitive to uppercase and lowercase letters. Other punctuation marks cannot be used except hyphens (-) in the label. The lowest-level domain name is written on the leftmost, and the highest-level domain is written on the far right. A full domain name consisting of multiple labels is limited to a total of 255 characters.

This matches the regular expression of the full domain name:

^(?=^. {3,255}$) [a-za-z0-9][-a-za-z0-9]{0,62} (\.[ A-ZA-Z0-9][-A-ZA-Z0-9]{0,62}) +$

Example: baidu.com

Match URL:

^(?=^. {3,255}$) (HTTP (s)?: \ /\/)? (www\.)? [A-za-z0-9] [-a-za-z0-9] {0,62} (\. [A-za-z0-9] [-a-za-z0-9] {0,62}) + (: \d+) * (\/\w+\.\w+) *$

Example: http://www.baidu.com

Match http URL:

^(?=^. {3,255}$) (HTTP (s)?: \ /\/)? (www\.)? [A-za-z0-9] [-a-za-z0-9] {0,62} (\. [A-za-z0-9] [-a-za-z0-9] {0,62}) + (: \d+) * (\/\w+\.\w+) * ([\?&]\w+=\w*) *$

Example: Http://www.tetet.com/index.html?q=1&m=test

Regular expressions match domain names, URLs, URLs

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.