Regular expression to determine if it is a website link address

Source: Internet
Author: User
Regular expressions are used to determine whether the URL is a website URL, such as Question & nbsp; for example, the URL format of the website is a normal link & nbsp; bbs. csdn. nettopicsnew? Forum_idPHPBase & nbsp; regular expression to determine if it is a website link address
For example, determine the website link format is a normal link http://bbs.csdn.net/topics/new? Forum_id = PHPBase

Share:


------ Solution --------------------
Echo filter_var ("http://bbs.csdn.net/topics/new? Forum_id = PHPBase ", FILTER_VALIDATE_URL );
// Http://bbs.csdn.net/topics/new? Forum_id = PHPBase

Echo filter_var ("http: bbs.csdn.net/topics/new? Forum_id = PHPBase ", FILTER_VALIDATE_URL );
// Null

See http://de3.php.net/manual/en/function.filter-var.php

------ Solution --------------------
The upstairs has better results, if you need regular expressions

$ Reg = '/\ B ((? # Protocol) https?
------ Solution --------------------
Ftp ):\/\/((? # Domain) [-A-Z0-9.] + )((? # File) \/[-A-Z0-9 + @ # \/% = ~ _
------ Solution --------------------
! :,.;] *)? ((? # Parameters )\? [A-Z0-9 + @ # \/% = ~ _
------ Solution --------------------
! :,.;] *)? /I ';

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.