i don't see no reason for regex π
$input = 'hallo,i,am,mrhappines,and,here,are,some,numbers,:,1,2,78,75.7,and,double,quotations,"';
//remove magic_quotes if neccessary
if (get_magic_quotes_gpc())
$input = stripslashes($input);
echo 'Hi there, you entered: Β»'.htmlentities($input).'Β«';
//escape things for mysql
$input = mysql_real_escape_string($input);
//convert to array
$input_array = explode(',', $input);
//re-convert and add '
$input = "'".implode("', '", $input_array)."'";
echo '<hr />Looking for entries<br />
WHERE columnname IN ('.$input.')';
output:
Hi there, you entered: Β»hallo,i,am,mrhappines,and,here,are,some,numbers,:,1,2,78,75.7,and,double,quotations,"Β«
---------------------
Looking for entries
WHERE columnname IN ('hallo', 'i', 'am', 'mrhappines', 'and', 'here', 'are', 'some', 'numbers', ':', '1', '2', '78', '75.7', 'and', 'double', 'quotations', '\"')