preg_replace 保留字母数字 + 拉丁语 + 表情符号
preg_replace keep alphanumeric + Latin + emojis
我需要过滤掉除字母数字、拉丁字符和表情符号之外的所有内容
$str="Hello José' [](){}✅., welcome";
想要的结果:
你好 José ✅ 欢迎
echo preg_replace("/[^\p{Latin} \wp-]/u",'',$str); // this is what i need
但我还需要保留表情符号✅
我有 2 个,但一个也删除了表情符号,另一个保留了表情符号但删除了其他所有内容。
我需要这 2 个组合
preg_replace("/[^\p{Latin} \wp-]/u",'',$str);
preg_replace("/[ -\x{2122}]\s+|\s*[ -\x{2122}]/u",'',$str);
preg_replace("/[^\p{Latin} \x{200d}\x{2600}-\x{1FAFF}0-9]/u",'',$str)
区域\x{2600}-\x{1F6FF}仍然包含一些不是表情符号的字符。详情见here。可能指定几个区域。我包括了数字 0-9。
我需要过滤掉除字母数字、拉丁字符和表情符号之外的所有内容
$str="Hello José' [](){}✅., welcome";
想要的结果:
你好 José ✅ 欢迎
echo preg_replace("/[^\p{Latin} \wp-]/u",'',$str); // this is what i need
但我还需要保留表情符号✅
我有 2 个,但一个也删除了表情符号,另一个保留了表情符号但删除了其他所有内容。 我需要这 2 个组合
preg_replace("/[^\p{Latin} \wp-]/u",'',$str);
preg_replace("/[ -\x{2122}]\s+|\s*[ -\x{2122}]/u",'',$str);
preg_replace("/[^\p{Latin} \x{200d}\x{2600}-\x{1FAFF}0-9]/u",'',$str)
区域\x{2600}-\x{1F6FF}仍然包含一些不是表情符号的字符。详情见here。可能指定几个区域。我包括了数字 0-9。