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 ';