RyanSF07 Posted July 6, 2009 Share Posted July 6, 2009 Hi Guys, I don't understand why the following permits % symbols. Isn't this saying "only allow upper and lower case letters, numbers, underscores, hyphens and/or white spaces"? That's what I'd like it to be --- what am I doing wrong? Thank you for your help ~ if (eregi("^[a-zA-Z0-9_\-]|[:space:]*$", $postedString) ) { $b = TRUE; } else { $b = FALSE; $content .= "<p>Letters, numbers, whitespaces, underscores, or hyphens only please.</p>\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/165003-solved-help-with-reg-expression/ Share on other sites More sharing options...
nrg_alpha Posted July 6, 2009 Share Posted July 6, 2009 Ryan, I would recommend ditching ereg and learn PCRE instead. ereg (part of POSIX) is considered depreciated as of PHP 5.3 and will not be included within the core of version 6. if(preg_match('#^[a-z0-9_\s-]*$#i', $postedString)){ ... Quote Link to comment https://forums.phpfreaks.com/topic/165003-solved-help-with-reg-expression/#findComment-870086 Share on other sites More sharing options...
RyanSF07 Posted July 7, 2009 Author Share Posted July 7, 2009 Thank you nrg_alpha. will do! Ryan Quote Link to comment https://forums.phpfreaks.com/topic/165003-solved-help-with-reg-expression/#findComment-870093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.