RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find First Middle Last Names and Suffix
Expression
(^\s*(?<firstname>(?!st\.?\s+)\w+\S*)\s+(?<middlename>(?!st\.?\s+)\w+\S*)\s+(?<lastname>(st\.?\s+)?\w+[^, ]*)(?:(,| ))*\s+(?<suffix>\w+\S*)\s*$)|(^\s*(?<firstname>(?!st\.?\s+)\w+\S*)\s+(?<lastname>(st\.?\s+)?\w+\S*)\s+(?<suffix>(jr)|(sr)|(ii)|(iii)||(iv)|(v)|(vi)|(vii)|(viii))\s*$)|(^\s*(?<firstname>(?!st\.?\s+)\w+\S*)\s+(?<middlename>(?!st\.?\s+)\w+\S*)\s+(?<lastname>(st\.?\s+)?\w+\S*)\s*$)|(^\s*(?<firstname>(?!st\.?\s+)\w+\S*)\s+(?<lastname>(st\.?\s+)?\w+\S*)\s*$)|(^\s*(?<lastname>(st\.?\s+)?\w+\S*)\s*$)
Description
Matches parts of a name. Last name only; first and last names; first, middle, and last names; first, middle, and last names and suffix; first and last names and suffix. This is very permissive so it's good for isolating name parts but doesn't validate whether a string is a reasonable name.
Matches
Loretta M.J.H Mac-Hogan-O'Brien, Jr.
Non-Matches
John Jacob JingleHeimer Smith Jr.
Author Rating: Not yet rated. Michael Yourshaw
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials