I'm trying to write a RegEx for names. Names can optionally start with a title (Dr., Mrs., etc) and otherwise contain two or three names with the middle name optionally abbreviated in the form (X.)
For instance the following names should be matched:
- Dr. Jeff T. Walker
- Susan B. Anthony
- Mr. Michael Binghamton
- Mrs. George Bush
The following should not be matched
- Garfield
- Dr. J
- T. Pain
- The United States of America
- February 15 2020
Here is what I have:
^(Dr\.|Mr\.|Mrs\.)?[A-Z][a-z]+\s([A-Z][a-z]+|[A-Z]\.)\s[A-Z][a-z]+?
im not quite sure where I'm going wrong here.