Exclusive: php url validation regular algorithm, the most powerful ever

Source: Internet
Author: User
Exclusive: PHP's URL verification regular algorithm, the most powerful in history after years of accumulation, gradually improved the written url verification algorithm functionisUrl ($ s) {returnpreg_match ('/^ http [s]? :\/\/'. '([0-9] {1, 3 }\.) {3} [0-9 Exclusive: php url verification regular algorithm, the most powerful

After years of accumulation, the url verification algorithm is gradually improved.

Function isUrl ($ s) {return preg_match ('/^ http [s]? :\/\/'. '([0-9] {1, 3 }\.) {3} [0-9] {1, 3 }'. // URL in IP format-199.194.52.184 '| '. // allow IP and DOMAIN (DOMAIN name) '([0-9a-z _! ~ * \ '()-] + \.) *'. // Third-level domain verification-www. '([0-9a-z] [0-9a-z-] {0, 61 })? [0-9a-z] \. '. // second-level domain verification '[a-z] {2, 6 })'. // top-level domain verification. com or. museum '(: [0-9] {1, 4 })? '. // Port-: 80 '((\/\?) | '. // If a file is contained, verify the file' (\/[0-9a-zA-Z _!~ \*\'\(\)\.;\? : @ & =\+ \ $, % #-\/] *)?) $/', $ S) = 1 ;}

If you still have problems, please paste the problematic url to continue to improve

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.