Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regex help needed for name validation.

 
Caine Lai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooooo... yeah that's what I want. Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic