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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find First and Last Name
Expression
^([A-Z][a-z]+)\s([A-Z][a-zA-Z-]+)$
Description
The pattern matches what would at least appear to be a first and last name, with an optional hyphenated last name. There is an obvious flaw that it can't distinguish between actual names and any two words that start with capital letters as noted in the matching text. Also, two part first names like "Mary Jo" can cause problems.
Matches
John Smith | Jane Smith-Doe | John McSmith | Abc Xyz
Non-Matches
john smith | J Smith | Mrs. Doe
Author Rating: Not yet rated. Michael Fienen
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

Title: Ignoring case
Name: Ian Lotinsky
Date: 9/28/2009 2:23:46 PM
Comment:
^([A-Za-z]+)\s([A-Za-z][A-Za-z-]+)$


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