What is a potential regex solution for an Array that contains these lines to find the first names and last names? (PYTHON)
John Doe
John, E. Doe
John, Doe E.
John, Doe
Jo hn, Doe Jr. (first name is "Jo hn")
John, Doe Doe III
John, E Doe
^([a-zA-Z]{2,}\s[a-zA-Z]{1,}'?-?[a-zA-Z]{2,}\s?([a-zA-Z]{1,})?)
^
// start of line
[a-zA-Z]{2,} // will except a name with at least 2
characters
\s
// will look for blank space between name and surname
[a-zA-Z]{1,} // needs at least 1 Character
\'?-?
// possibility of **'** or **-** for double barreled
and hyphenated surnames
[a-zA-Z]{2,} // will except a name with at least 2
characters
\s?
// possibility of another whitespace
([a-zA-Z]{1,})? // possibility of a 2nd surname
Get Answers For Free
Most questions answered within 1 hours.