preg_replace("/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{2600}-\x{ 26FF}\x{2700}-\x{27BF}]/u","","This is the nickname")
https://xmy.xingzs.top/
WBOY2023-06-29 10:50:35
function filterSpecialChars($nickname) { $pattern = '/[^\p{L}\p{N}\s]/u'; $filteredNickname = preg_replace($pattern, '', $nickname); return $filteredNickname; }
$nickname = "微信昵称@#特殊字符"; $filteredNickname = filterSpecialChars($nickname); echo $filteredNickname; // 输出:微信昵称特殊字符