怎样实现用正则表达式匹配一中文字符串?
例如:
用户名:<input type="text" name="" id="" value="">
怎样用正则表达式验证用户的输入合法性?关键是:::当用户输入中文时怎样验证???
麻烦哪位按照以上的例子,给个答案(代码)谢了~~~

解决方案 »

  1.   

    [a-zA-Z0-9-_\.\u4e00-\u9fa5]适合大小写字符和“-”“_”“.”和中文字符
      

  2.   

    我用的是editplus编辑器,用你给我的代码显示错误,如下:
    Warning: preg_match() [function.preg-match]: Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 14 in D:\wamp\www\2third\3-1.php on line 26
    这是怎么回事啊?
      

  3.   

    我用的是editplus编辑器,用你给我的代码显示错误,如下:
    Warning: preg_match() [function.preg-match]: Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 14 in D:\wamp\www\2third\3-1.php on line 26
    这是怎么回事啊?
      

  4.   

    刚刚没说清楚,我用的是editplus编辑器,用你给我的代码,我输入的是两个中文汉字,显示错误,如下:
    Warning: preg_match() [function.preg-match]: Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 14 in D:\wamp\www\2third\3-1.php on line 26
    这是怎么回事啊?
      

  5.   


    var_dump(preg_match('/[a-zA-Z0-9-_\.\\\u4e00-\\\u9fa5]/i','中文dkafj'));