Regular expression for first and last name

后端 未结 24 1949
温柔的废话
温柔的废话 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:09

    If you want the whole first name to be between 3 and 30 characters with no restrictions on individual words, try this :

    [a-zA-Z ]{3,30}
    

    Beware that it excludes all foreign letters as é,è,à,ï.

    If you want the limit of 3 to 30 characters to apply to each individual word, Jens regexp will do the job.

提交回复
热议问题