Regular Expressions 101

Community Patterns

Community Library Entry

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 - 3 years ago