可能重复:
Regular expression to remove anything but alphanumeric & spaces (in PHP)
我想要
//before preg_replace -> Hi (Jimmy),
$string = preg_replace('/[^\da-z]/i', '', $string);
//after current preg_replace -> HiJimmy
//what it should be -> Hi Jimmy
preg_replace删除除空格外的所有字母数字字符。这可能吗?
答案 0 :(得分:7)
只需为您的论坛添加空间:
$string = preg_replace('/[^\da-z ]/i', '', $string);
// ^ Notice the space here