我正在尝试从服务器端验证表单数据。 我感兴趣的是用户只需用波斯字符填写表格。
我正在使用这段代码:
$name=trim($_POST['name']);
$name= mysql_real_escape_string($name);
if (preg_match('/^[\u0600-\u06FF]+$/',str_replace("\\\\","",$name))){$err.= "Please use Persian characters!";}
但它不起作用!
这是一个警告:
Warning: preg_match() [function.preg-match]: Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 3 in C:\xampp\htdocs\site\form.php on line 38
我能做什么?
最佳答案
这个“应该”工作...
** 在开头 [ 后添加一个 ^ 以从匹配中排除阿拉伯语/法西语字符...
if (preg_match('/^[^\x{600}-\x{6FF}]+$/u', str_replace("\\\\","",$name)))
关于php - 使用 preg_match 检测字符串中的波斯语 (farsi) 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4621727/