Re: HELP with Regular Expressions

From: Date: Tue, 21 Aug 2001 23:55:30 +0000
Subject: Re: HELP with Regular Expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63830@lists.php.net to get a copy of this message
> if (($hostname) || ($HOSTNAME)) { > $hostname= trim($hostname); > if ($HOSTNAME) > $hostname = trim($HOSTNAME); > if (!eregi("^[-a-z0-9-]+(\.[a-z0-9-]+)*$ ", $hostname)) { > print_error("your <b>your hostname</b> is invalid"); > } > $HOSTNAME = $hostname; > } Things I know are wrong: 1. I don't think you want a - before the a-z 2. You have ()s around only the stuff *AFTER* the first character. So you are losing that stuff in the ()s to be saved in the third argument you're not providing to eregi()... 3. You didn't escape your \ from PHP, nor eregi(). You need \\\\, I think. 4. You have a space after the $, which is wrong. 5. You didn't escape the $ from PHP with \ Warning: I hate Regex, and have no idea if fixing these will get you any closer to what you want. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#63830) next »