简体   繁体   English

验证名字和姓氏

[英]validate firstname and lastname

First my English is not so good, so please understand what I am trying to say. 首先,我的英语不太好,所以请理解我的意思。

I previously asked this question , but I did not get an answer that I wanted. 我以前曾问过这个问题 ,但没有得到想要的答案。 That's why I write this question. 这就是为什么我写这个问题。


I want users to be able to set their name in any language. 我希望用户能够以任何语言设置其名称。 But there are some rules: 但是有一些规则:

Names can't include: 名称不能包括:

  • Symbols, numbers, unusual capitalization 符号,数字,大写
  • Characters or punctuation or icon that is not in any language, like this(⧇ ⧈ ⧉ ⧊ ⧋ ⧌⛋ ⛌ ⛍ ⛎ ⛏ ⛐ ⛑ ⛒ ⛓ ⛔) 诸如此类的非语言字符,标点符号或图标(⧇⧇⧉⛔⛔⛔⛔)
  • Characters from multiple languages 多种语言的字符

How can I validate names with these kind of rules? 如何使用此类规则验证名称?

It is a suggestion, you can give a try to Regual Expressions, named also Regex. 这是一个建议,您可以尝试一下正则表达式,也称为Regex。

Check this out: 8 Regular Expressions You Should Know 检查一下: 您应该知道的8个正则表达式

Hope it gives you a hint. 希望它能给您提示。

Sounds like you need some pretty specific preg_match rules. 听起来您需要一些非常具体的preg_match规则。 If you take some of the advice from the previous question you asked and mash that up with that language detection service you found, you should be able to detect the language, then compare the first and last name against a pre-defined list of unacceptable characters and, if you find them, reject the name. 如果您从上一个问题中得到了一些建议,并将其与找到的语言检测服务融合在一起,则应该能够检测到该语言,然后将名字和姓氏与预定义的不可接受字符列表进行比较并且,如果找到它们,则拒绝该名称。 After that check, you should be able to check the first name language, the last name language, then compare those results and figure out if they are in the same language and, if not, reject. 进行检查之后,您应该能够检查姓氏语言,姓氏语言,然后比较这些结果并找出它们是否使用相同的语言,如果不是,则拒绝。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM