On Thu, March 1, 2007 6:14 pm, Myron Turner wrote: > 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. The reason that a single \ in front didn't work is that \ is ALSO special character for ' in PHP, and it just escapes the - so that you have NOT sent \- to EREG, but sent it the same thing you were sending it before you added \ You would need \\ inside of '' (or "") in PHP to get a single \ sent to EREG which would then be used by EREG to escape the - '...\\- ,/' PHP takes \\- to produce \- which EREG takes to produce [character -] instead of [range operator -] You should probably review the "strings" page at the beginning of the PHP manual. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php