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
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: 39548
    
  27
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 - updated with new look and Ping home screen widget
Caine Lai
Greenhorn

Joined: Sep 21, 2005
Posts: 15
Ooooo... yeah that's what I want. Thanks a lot.
 
Don't get me started about those stupid light bulbs.
 
subject: Regex help needed for name validation.
 
Similar Threads
regular expression question
Decipher regular expression
Regular expression to replace all invalid xml characters
Validating domain name with struts validator
[regex help]Find EXACT characters in a String.