Title |
Test
Find
Pattern Title
|
Expression |
(?<FirstName>[A-Z]\.?\w*\-?[A-Z]?\w*)\s?(?<MiddleName>[A-Z]\w*|[A-Z]?\.?)\s?(?<LastName>[A-Z]\w*\-?[A-Z]?\w*)(?:,\s|)(?<Suffix>Jr\.|Sr\.|IV|III|II|) |
Description |
A regex that attempts to accurately parse the elements from a proper name where the format is in <<First, Last>> order or some permutation of that order. Critiques and suggestions for improvement are welcome. |
Matches |
David F Walker | J. S. Smith, Jr. | Catherine Zeta-Jones |
Non-Matches |
oscar peterson |
Author |
Rating:
David Walker
|
Source |
|
Your Rating |
|
Title: Suggestion
Name: Philippe Dykmans
Date: 11/26/2010 8:42:48 PM
Comment:
Hi,
Very useful pattern (for me). It would be even nicer if one could somewhere enumerate those prefixes that typically go with the last name. Like:
'de' (Helene de Fougerolles)
'de la' (Astrid de la Vega)
'van de' (Monique van de Ven)
'di' (Leonardo di Caprio)
It's probably quite easy. But i'm not so familiar with Regex.
Regards,
Philippe ([email protected])
Title: Thanks!
Name: Nick
Date: 1/20/2005 2:58:27 AM
Comment:
Thanks- I used this as a base for parsing names of an automated book scanning program. Lots of the author names didn't have a middle initial, and I made some other changes:
(?<FirstName>[A-Z]\.?\w*\-?[A-Z]?\w*)\s?
(?<MiddleName>\b[A-Z]\w*|[A-Z]?\.?)\s?
(?<LastName>\b[A-Z]\w*\-?[A-Z]?\w*)
(?:,?\s|)
(?<Suffix>D\.?D\.?S\.?|[DJS]r\.$|[MOD]\.?D\.?|[IVX]+|)
Will now also match:
David Walker
Catherine Zeta-Jones, M.D.
Fred Made-Up, DDS.
King George, VIII