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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Full Name - Supports hyphens and apostrophes
Expression
^(?-i:[A-Z]{1}[a-z]+(?<fnh>[-]{1})?(?(fnh)[A-Z]{1}[a-z]+)\s[A-Z]{1}(?<apos>[']{1})?(?(apos)[A-Z]{1})[a-z]+(?<lnh>[-]{1})?(?(lnh)[A-Z]{1}[a-z]+))$
Description
This pattern allow a first and last name to be tested to ensure that each name begins with a capital letter and is separated by just one space. The pattern also ensures that only one hyphen can be placed in either the first or last name and the succeeding character must be capitalized. If an apostrophe is used in the last name it too must be succeeded by a capital letter.
Matches
Anne-Marie O’Conner-Smith | Anne Smith | Mary-Jo O’Conner | Mary Smith-Kline
Non-Matches
Anne--Marie Smith | Mary OConner | Mary-jo Wilson
Author Rating: Not yet rated. Philip Ragan
   Displaying page 1 of 1 pages; Items 1 to 1

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