Search code examples
phpregexstringparsingstring-parsing

php regular expression checking for name


Possible Duplicate:
PHP regex to check a English name

I'm trying to write a regular expression that will check a name field that i have for a user.

I want it to check for

Firstname SPACE Middle initial SPACE Last name.

I know for singular letters for the middle intitial I'll need [a-z] but I'm not sure how to do the full words for first and last name and the spaces in between.


Solution

  • ^[A-Za-z]+\s[A-Za-z]\s[A-Za-z]+$