• 使用preg_match
  • 必须使用u flag
    • 这个修饰符添加的额外的功能,与Perl的PCRE不兼容。
    • Pattern和字符串均为UTF-8编码。
    • PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32开始支持。
    • 从PHP 4.3.5开始对UTF-8的有效性进行检查。
    • 5/6个八进制字符表示UTF-8字符从 PHP 5.3.4 开始不再支持(resp. PCRE 7.3 2007-08-28)。
/^[\x{4e00}-\x{9fa5}]+$/u
  • JSON 中的不同, Javascript使用的是\x4e00,不需要花括号

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-12-23
  • 2021-06-07
  • 2021-05-27
  • 2022-12-23
猜你喜欢
  • 2021-06-28
  • 2021-06-24
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
相关资源
相似解决方案