Regex to validate names

前端 未结 6 1739
一个人的身影
一个人的身影 2021-01-19 12:04

I would like to create a regex which validates a name of a person. These should be allowed:

  • Letters (uppercase and lowercase)
  • -
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 12:21

    Is there an easy way to check for correct human names?

    This has been discussed several times. I'm fairly certain that the only thing that people can agree on is that in order to exist a name cannot be a empty string, thus:

    ^.+$
    

    (Yes, I am aware that this is probably not what OP is looking for. I'm just summarizing earlier Q&As.)

提交回复
热议问题