Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2003, 04:33 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hows this for a URL validation?

I've just completed this in RegExp format and I just wondering if it looks ok to you guys.::

ereg("^[http]{1}(://){1}[_a-z0-9-]+(\.){1}[a-z]+$");

I try to make it match a url with exactly one "http://" followed by one of more characters which is the followed by a dot (.) indicating the domain...then followed by x amount of characters for the domain. So, how is it looking?

Thanks
-kyle

 
Old August 4th, 2003, 04:38 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BTW: I think it's really great that Wrox made a comeback...this place is awesome. The new forum is also quite better than the old one =)

 
Old August 5th, 2003, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Haha, asking a PHP developer to part with his or her regular expressions is like asking them for their underpants :)

I guess if you're happy to just check HTTP-scheme URLs, then this might simplify things a little:

(^[http://]{1}([^[:space:]]*)[:alnum:]+[(\.){1}[:alnum:]]+$)

I prefer "alnum", ("alphanumeric"), presonally, to that "a-z0-9" jumble. I think it looks a little less cumbersome. Either way (yours or mine) this only checks as far as the domain, of course.

Maybe:

(^[http://]{1}([^[:space:]]*)[:alnum:]+[(\.){1}[:alnum:]]+(\/)[[:alnum]#?/&=]$)

Will allow for full URLs, including querystrings, internal anchors links, etc. Haven't tried it, I must admit.

Replace [http://] at the front with [[:alpha:]+://], and you'll be able to cope with https://, ftp:// or telnet:// et cetera.

BTW, (and FWIW) Wrox is "back" the way MV Agusta is "back":
different design team from a different era, with different manufacturers, in a different factory, owned by different owners, from a different country, using different materials....
But, for all that, still painted red, still called "Wrox", and (I sincerely hope, in wishing them all the best) winning races again, soon, perhaps.

Quote:
quote:Originally posted by Kyle Ketterer
 I've just completed this in RegExp format and I just wondering if it looks ok to you guys.::

ereg("^[http]{1}(://){1}[_a-z0-9-]+(\.){1}[a-z]+$");

I try to make it match a url with exactly one "http://" followed by one of more characters which is the followed by a dot (.) indicating the domain...then followed by x amount of characters for the domain. So, how is it looking?

Thanks
-kyle




Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Redirect based on given URL somnath.kartic VS.NET 2002/2003 1 August 2nd, 2012 08:21 AM
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
ASP/ASPX W3C validation URL OldCoder HTML Code Clinic 4 April 8th, 2006 11:58 PM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.