Correct usage is: /,,([,]+)?|^,|,$|\b,\b|\s,/
$comma[0] = '/,,([,]+)?/';
$comma[1] = '/^,/';
$comma[2] = '/,$/';
$comma[3] = '/\b,\b/';
$comma[4] = '/\s,/';
$analyst = preg_match($comma, $_POST['analyst'])
? mysql_real_escape_string($_POST['analyst']) : NULL;
I am trying to detect commas from the users input, each regex is defined properly, but I do not understand why it isn't passing them into the if statement.
Edit:
if I change this:
$analyst = preg_match('test', $_POST['analyst'])
? mysql_real_escape_string($_POST['analyst']) : NULL;
then it works, this makes no sense.
preg_replacedoes.str_pos( $_POST['analyst'], ',' )wouldn't suffice?