Re: Regex for Validating URL
| From: | Manuel Lemos | Date: | Thu, 02 Sep 2004 14:43:11 +0000 |
| Subject: | Re: Regex for Validating URL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195603@lists.php.net to get a copy of this message | ||
Hello,
From: "Nick Wilson" <nick@stylesheet.org>
Does anyone have the regex to make sure an http address is full and without error? like http://www.example.comUsually I use this expression: '^(http|https)\://(([-!#\$%&\'*+.0-9=?A-Z^_`a-z{|}~^?]+\.)+[A-Za-z]{2,6})(\:[0-9]+)?(/)?/' You may also want to try this forms generation and validation class that comes with special URL auto-completion field support so you can do for instance simply type www.php.net and it automatically expand to http://www.php.net/ and conform to a more strict validation expression like the above without making the user type it all. http://www.phpclasses.org/formsgeneration -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html