RE: [PHP] Re: eregi problem

From: Date: Mon, 04 Apr 2005 13:28:42 +0000
Subject: RE: [PHP] Re: eregi problem
Groups: php.general 
Request: Send a blank email to php-general+get-212169@lists.php.net to get a copy of this message
> -----Original Message----- > From: M. Sokolewicz [mailto:tularis@php.net] > Sent: Monday, April 04, 2005 3:08 PM > > Putting the ^ _inside_ [] means NOT, so if any of the chars a-z0-9 is in > the string it´s NOT matched. > actually, that's not entirely correct. The regexp basically means that > if there is any character in the string which is NOT alphanumeric, then > it is matched. So basically it returns true if there is a > non-alphanumeric char, and false otherwise. However, AFAIK the regexp > should be delimited, since if it isn't it behaves "differently"... I > just can't remember how differently it is exactly =/ It _is_ correct. [^] means that whatever is in the [] must not be in the checked var to be true! Look in "mastering regular expressions" if You´re in doubt. There´s an example [^1-6] meaning if a digit between 1 and 6 is not in the value checked, it´s true: $var1 = "123"; $var2 = "789"; if(ereg("[^1-6]", $var1)) print "$var1 is true"; else print "$var1 is false"; returns false if(ereg("[^1-6]", $var2)) print "$var2 is true"; else print "$var2 is false"; returns true It´s untested though :-) -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper

« previous php.general (#212169) next »