How to Validate Full Name

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
chizeng
Forum Newbie
Posts: 11
Joined: Sun Feb 28, 2010 10:52 pm

How to Validate Full Name

Post by chizeng »

Hi all,

I am looking for a regex pattern to validate names, full or abridged, such as:

Sam Johnson Jr.
Mr. O' Dougell
sam thayer
jack

So basically only alphabetic and space characters except for " ' " and "." .

Does anyone have any suggestions?

Thanks so much.
User avatar
Sofw_Arch_Dev
Forum Commoner
Posts: 60
Joined: Tue Mar 16, 2010 4:06 pm
Location: San Francisco, California, US

Re: How to Validate Full Name

Post by Sofw_Arch_Dev »

So basically only alphabetic and space characters except for " ' " and "." .
Sounds like you have a handle on it already. What have you tried so far? You don't seem to be enforcing or expecting capitalization. Are you planning on validating the name or name parts against a dictionary? Without a dictionary anything you write will probably have to allow junk names.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: How to Validate Full Name

Post by Jonah Bron »

[a-zA-Z\.'\s]{2,60}

Any of the given characters, (a-z, A-Z, escaped period, apostrophe, any whitespace character) occurring between 2 and 60 times.
MichaelR
Forum Contributor
Posts: 148
Joined: Sat Jan 03, 2009 3:27 pm

Re: How to Validate Full Name

Post by MichaelR »

User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: How to Validate Full Name

Post by Apollo »

chizeng wrote:Does anyone have any suggestions?
Yes: don't do it. My neighbour (whose name is 张張刘劉) might want to use your website as well!

What, you're only aiming at western people? My uncle from Iceland (whose name is Friðrik Þór Guðnæson) might want to use your website as well :)
Post Reply