Re: Eregi error

From: Date: Fri, 02 Mar 2007 00:14:11 +0000
Subject: Re: Eregi error
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-249696@lists.php.net to get a copy of this message
Roberto Mansfield wrote:
Myron Turner wrote:
M.Sokolewicz wrote:
    
$pattern = '^[a-z0-9\!\_ \.- ,/]*$'; if(!eregi($pattern, $input)){
the problem is that the hyphen is interpreted as regex range operator: [a-z0-9\!\_ \.- ,/]
Rewrite this as
                                   [a-z0-9\!\_ \. ,/-]
with the hyphen in the last position.
    
Or just escape the hyphen: \- The position won't matter.
Actually, I tried that, but it didn't work. It still saw the hyphen as an operator. The other thing about this is that the hyphen is followed by a space, so that it's asking for a range between the period and the space, which you can't do, since the space character has a lower ascii value than than the period. The space is more obvious in a monospaced font. -- _____________________ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/

« previous php.general (#249696) next »