Regular expression for first and last name

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

    Don't forget about names like:

    • Mathias d'Arras
    • Martin Luther King, Jr.
    • Hector Sausage-Hausen

    This should do the trick for most things:

    /^[a-z ,.'-]+$/i

    OR Support international names with super sweet unicode:

    /^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,.'-]+$/u

提交回复
热议问题