Regular Expressions 101

Community Patterns

LastName, FirstName MiddleName(s), Suffix

0

Regular Expression
ECMAScript (JavaScript)

/
^(?<last>[^,\n\r]+), *(?<first>[^,\s]+)*(?: +(?<middle>[^,\n\r]+)+?)*(?:, *(?<suffix>[^\n]+))*.*$
/
gm

Description

This Regex parses out the LastName, FirstName, MiddleName(s) (optional) and Suffix (optional).

The String must have at least two words separated by a comma to match.

Submitted by Ryan Toner - 2 years ago