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"; } 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)){ ... 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 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
Archived
This topic is now archived and is closed to further replies.