Re: need help on a ereg stmt. validating website adress

From: Date: Sat, 18 May 2002 22:13:23 +0000
Subject: Re: need help on a ereg stmt. validating website adress
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98297@lists.php.net to get a copy of this message
On Sat, 18 May 2002, andy wrote: > I would like to validate a website adress. Unfortunatelly my eregi stmt does > not work: > > if (eregi("^@([0-9a-z][0-9a-z-\.]+)\.([a-z]{2,3}))", $website)){ // not a > link > > I am getting the error msg: > Warning: REG_ERANGE in extend.inc on line 94 > > does anybody know whats wroong with that? For one thing, your regex doesn't match any definition of "website address" that I've ever seen. Look up the spec for URLs at http://www.w3.org/Addressing/ . In the very least, you should not arbitrarily exclude valid domains just because the last part is not 2 or 3 characters - what about .info, .museum, etc.? And what's the @ for? As for your error, I'd guess it's because you wrote [0-9a-z-\.] rather than [0-9a-z\-\.] (escaping the -). miguel

« previous php.general (#98297) next »