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] Link to comment https://forums.phpfreaks.com/topic/132081-solved-help-please/ 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 } Link to comment https://forums.phpfreaks.com/topic/132081-solved-help-please/#findComment-686400 Share on other sites More sharing options...
Andy-H Posted November 10, 2008 Author Share Posted November 10, 2008 Works perfectly, thankyou Link to comment https://forums.phpfreaks.com/topic/132081-solved-help-please/#findComment-686405 Share on other sites More sharing options...
corbin Posted November 10, 2008 Share Posted November 10, 2008 No problem ;p. Link to comment https://forums.phpfreaks.com/topic/132081-solved-help-please/#findComment-686407 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.