Regular expression for first and last name

后端 未结 24 2201
温柔的废话
温柔的废话 2020-11-22 10:03

For website validation purposes, I need first name and last name validation.

For the first name, it should only contain letters, can be several words with spaces, an

24条回答
  •  不知归路
    2020-11-22 10:29

    This is what I use.

    This regex accepts only names with minimum characters, from A-Z a-z ,space and -.

    Names example:

    Ionut Ionete, Ionut-Ionete Cantemir, Ionete Ionut-Cantemirm Ionut-Cantemir Ionete-Second
    

    The limit of name's character is 3. If you want to change this, modify {3,} to {6,}

    ([a-zA-Z\-]+){3,}\s+([a-zA-Z\-]+){3,}
    

提交回复
热议问题