PHP preg_match 语言依赖解释错误

土耳其语字符 Ş İ Ö Ü 不支持。我累极了。


<?php

header('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

}


?>


慕尼黑8549860
浏览 68回答 1
1回答

临摹微笑

\pL匹配任何字母(包括重音字母),因此您可以使用以下内容:preg_match('/^[\pL0-9&nbsp;]+$/u',&nbsp;$test)同样,\d匹配任何数字,\s匹配任何空格字符,所以你也可以使用以下内容:preg_match('/^[\pL\d\s]+$/u',&nbsp;$test)
打开App,查看更多内容
随时随地看视频慕课网APP