aspose file tools*
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 Spring in Action this week in the Spring 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
Marshal

Joined: Mar 22, 2005
Posts: 42278
    
  64
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.


Ping & DNS - my free Android networking tools app
Caine Lai
Greenhorn

Joined: Sep 21, 2005
Posts: 15
Ooooo... yeah that's what I want. Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regex help needed for name validation.