Tried looking around for a regex pattern for a full name and just can’t seem to find one.
Ideally would match like
Tom Franklin
tom Franklin
tom franklin
tom franklin-jones
i.e. allow 1 space in the middle and some basic hyphens etc but thats all. Does any one know how to do this ?
Edit: Including
René Hadron van der Ööps
You can use
/([\p{L}'-]+) ([\p{L}'-]+)/to catch all possible letter. Or/([a-z'-]+) ([a-z'-]+)/ito catch only ascii letters.The group
([\p{L}'-]+)means[\p{L}'-]repeated at least one time. And\p{L}means any unicode letter. The-at the end means that “-” is allowed in names.Note :
When you capture characters with
[]the hyphen must be either at the start of your characters set or at the end.Edit :
Mr. O’Brien is happy now.
Resources :