doudouba4520 2012-02-16 14:23
浏览 91
已采纳

如何检查该字符串是否包含任何语言的字母?

My current regex is /^[a-zA-Z]+( [a-zA-Z]+)*$/. It works for names like:

John Smith

Anyway, the site is international and name could be like this, for example:

Jānis Bērziņš

It's a valid name, but regex will fail to validate it because of ā, ē and š chars.

The one way would be to type all chars that are allowed, but then the list would be HUGE!

I'm looking for easier way to do that. Maybe black-list instead of white-list approach?

Thanks in any advice!

  • 写回答

2条回答 默认 最新

  • dtpa98038 2012-02-16 14:26
    关注

    Use a regex in UTF-8 mode with the appropriate Unicode character propert(y/ies).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振
  • ¥20 pip2.40更新pip2.43时报错
  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal
  • ¥20 OPENVPN连接问题