[PHP] need help on a ereg stmt. validating website adress
Hi there, 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? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help on a ereg stmt. validating website adress
andy [EMAIL PROTECTED] wrote: Hi there, 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 The second charset: [0-9a-z-\.] has an errant hyphen (-). In this case the hyphen should be the first or last character. Also, the . char loses its meaning inside square brackets, so you don't need to escape it. Eg: [0-9a-z.-] -- Richard Heyes ___ This mail sent using V-webmail - http://www.v-webmail.co.uk I did change the comment to what you suggested: if (eregi(^@([0-9a-z][0-9a-z-.]+)\.([a-z]{2,3})), $website)){ // not a link but this seams not to work as well. It is still possible to post a website like this: http://website So somehow the last part does not work checking for dot and 2 or 3 char. does somebody have an idea on that? Thanx, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help on a ereg stmt. validating website adress
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php