我在网络上找到了许多不同的模式(测试了它们所有),我还为页面添加了编码,但似乎没有什么作用。这是我的代码:
<?php header('Content-Type: text/html; charset=utf-8'); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$teststring="cc12cž";
$pattern = "/^[p{L}\p{M}\a-zA-Z*0-9\s\-]+$/u";
if(preg_match($pattern, $teststring))
{echo"IT IS ALFANUMERIC";}
else
{echo"ERROR";}
?>
</body></html>
这是我尝试过的内容
//$pattern = "/^[\p{L}\p{M}\a-zA-Z*0-9\s\-]+$/u";
//$pattern = "/^[p{L}\p{M}\a-zA-Z*0-9\s\-]+$/u"
//$pattern ='/^[a-zA-Z\p{Cyrillic}\d\s\-]+$/u'
//$pattern ="/(*UTF8)^[[:alnum:]]+$/"
//$pattern ="/^[a-zA-Z\p{Cyrillic}\p{Cyrillic}]+$/u"
p{L}
前面加上反斜杠,它就可以工作了。https://regex101.com/r/iY8cM3/3 - Charlotte Dunoisž
不是西里尔字母,更像是波兰字母表中带有一些额外重音符号的标准字母。这是西里尔字母:на здоровье。 - maracamb_ereg
代替 preg_match 怎么样? - Elzo Valugi