Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
^((?:[ \-]?[A-Z][a-z]+|[A-Z][a-z]?\.?)+)(?: ?[A-Z]\.?)* ([A-Za-z]{,3}(?:[ \-]?[A-Z]'?[A-Z]?[a-z]+\.?,?)+[A-Z \-.]*)$
"
gm

Description

Separate first and last names. Capitalization matters. Ignore middle initials but allow middle names. Multiple last names may be mistaken for middle names. Groups could be changed to capture middle names separately, middle initials, etc.

Submitted by anonymous - 2 years ago