Andy-H Posted November 10, 2008 Share Posted November 10, 2008 I am trying to write a regular expression that will only allow alphanumeric characters, spaces and commas. I tried using if (ereg("[^[A-Za-z0-9 ,]]", ($_POST['crimes'][$i]))){ But it is allowing apostrophes too, what am I doing wrong?? Thanks for answers, Andy-H [A.K.A - REGEX N00B] Quote Link to comment Share on other sites More sharing options...
corbin Posted November 10, 2008 Share Posted November 10, 2008 if(preg_match('/^[a-zA-Z0-9, ]+$/', $str)) { //valid } Quote Link to comment Share on other sites More sharing options...
Andy-H Posted November 10, 2008 Author Share Posted November 10, 2008 Works perfectly, thankyou Quote Link to comment Share on other sites More sharing options...
corbin Posted November 10, 2008 Share Posted November 10, 2008 No problem ;p. Quote Link to comment 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.