samedi 9 mai 2015

Regular expression for getting first and last name ignoring middle names

I'm searching a regular expression that could give me the first and last name in a string that is a complete name.

I searched but I didn't find one that fit my needs. For instance:

  • Abc Def Ghi Jkl ---> Abc Jkl
  • Aéc Def Gài Mkl ---> Aéc Mkl
  • Aéc-Def Gài Mkl ---> Aéc-Def Mkl
  • Aéc Def Gài-Mkl ---> Aéc Gài-Mkl
  • Afd ---> Afd

How can I build a regex to return me what is on the right side when the string is what is on the left?

Aucun commentaire:

Enregistrer un commentaire