为了账号安全,请及时绑定邮箱和手机立即绑定

PHP preg_match 语言依赖解释错误

PHP preg_match 语言依赖解释错误

PHP
慕尼黑8549860 2023-03-04 17:37:21
土耳其语字符 Ş İ Ö Ü 不支持。我累极了。<?phpheader('Content-Type: text/html; charset=utf-8');$test = "azAZ09andSpace supported but this turkish characters Ş İ Ö Ü like not supported";        //So it goes to the "else block".if (preg_match('/^[a-zA-Z0-9 ]+$/', $test)){echo "match";}else{echo "not match"; //return false. Because Ş İ Ö Ü like not supported}?>
查看完整描述

1 回答

?
临摹微笑

TA贡献1982条经验 获得超2个赞

\pL匹配任何字母(包括重音字母),因此您可以使用以下内容:

preg_match('/^[\pL0-9 ]+$/u', $test)

同样,\d匹配任何数字,\s匹配任何空格字符,所以你也可以使用以下内容:

preg_match('/^[\pL\d\s]+$/u', $test)


查看完整回答
反对 回复 2023-03-04
  • 1 回答
  • 0 关注
  • 60 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信