This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Regex help needed for name validation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regex help needed for name validation." Watch "Regex help needed for name validation." New topic
Author

Regex help needed for name validation.

Caine Lai
Greenhorn

Joined: Sep 21, 2005
Posts: 15
Could someone please help me with creating a regex that will validate user input for a name field?

This is what I have so far. See anything missing? The special characters listed are for matching common european characters used in names. I'm not too worried about complete localized names unless there is a simple way to do this.

Current Regex Pattern: ^([A-Za-z�-��-��-� '`\\.,])+

Thanks!


Online collaboration made simple: <a href="http://www.rallypointhq.com" target="_blank" rel="nofollow">http://www.rallypointhq.com</a>
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42954
    
  73
You can catch all letters, accented or not, by using a shorthand like "\p{L}". It's explained in the javadocs for java.util.regex.Pattern.
Caine Lai
Greenhorn

Joined: Sep 21, 2005
Posts: 15
Ooooo... yeah that's what I want. Thanks a lot.
 
rocket mass heater kickstarter
 
subject: Regex help needed for name validation.