I have asked this before but cant find a response/answer to the same.
I do have tags like this..
news,门户,æ–°é—»,portal,网易,163,china,门户ç
I need to extract only news,portal,163,china
from above. how can I do it in php??
I have asked this before but cant find a response/answer to the same.
I do have tags like this..
news,门户,æ–°é—»,portal,网易,163,china,门户ç
I need to extract only news,portal,163,china
from above. how can I do it in php??
Replace anything that's not a letter or comma:
$sString = preg_replace('/[^a-z0-9,]+/i', '', $sString);
$sString = preg_replace('/,{2,}/', ',', $sString);
Assuming you want to keep only ascii alpha-numeric parts of this string, the following code will work:
$str = explode(',', $str);
$str = preg_grep('#^[[:alnum:]]+$#', $str);
$str = implode(',', $str);
This one too:
$str = preg_replace('#(^([^[:alnum:],]+,)+|,[^[:alnum:],]+)#', '', $str);
Which both return news,portal,163,china
echo str_replace(',,', ',', preg_replace('~[^a-zA-Z0-9,]~i', '', $searchString));
s/([[:alnum:]\ ]+,?|) .*? ([[:alnum:]\ ]+,?|) /$1$2/xsg
or
s/[\x{80}-\x{1fffff}]+,?//g