Php正则表达式问题符号

Php正则表达式问题符号,php,regex,preg-match,Php,Regex,Preg Match,在发送邮件功能中,我有解码标题的代码: preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); 如果in string是一个符号,例如ä(März),那么它将返回一个空字符串。请帮助我,我如何修复它(也用于德语符号)? 谢谢 只需为unicode添加/u标志: preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/u', $str, $match

在发送邮件功能中,我有解码标题的代码:

preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
如果in string是一个符号,例如
ä
(März),那么它将返回一个空字符串。请帮助我,我如何修复它(也用于德语符号)?
谢谢

只需为unicode添加
/u
标志:

preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/u', $str, $matches);
#                                               here __^

只需为unicode添加
/u
标志:

preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/u', $str, $matches);
#                                               here __^

尝试在分隔符外添加
u
标志:

$str="März";
preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/u', $str, $matches);
print_r($matches);
如果您的PHP文件编码为UTF-8,您还可以在模式中使用特殊字符:

preg_match_all('/[Mäz]/u', $str, $matches);
print_r($matches);

您可以测试它。

尝试在分隔符之外添加
u
标志:

$str="März";
preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/u', $str, $matches);
print_r($matches);
如果您的PHP文件编码为UTF-8,您还可以在模式中使用特殊字符:

preg_match_all('/[Mäz]/u', $str, $matches);
print_r($matches);
你可以测试一下