Proper use: /,,([,]+)?|^,|,$|\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 user input, each regular expression is defined correctly, but I do not understand why it does not pass them to the if statement.
Edit:
if i change this:
$analyst = preg_match('test', $_POST['analyst'])
? mysql_real_escape_string($_POST['analyst']) : NULL;
then it works, it does not make sense.
source
share