• Post Reply Bookmark Topic Watch Topic
  • New Topic

regex in java  RSS feed

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm using regex API in Java 5. May I ask how I would for a pattern like 5'11" or 6'0" for validating height field? Thanks!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about "[0-9]'[0-9][0-1]?\""
I don't know this metric system so I don't know the actual requirements...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Timothy Sam:
Hi, I'm using regex API in Java 5. May I ask how I would for a pattern like 5'11" or 6'0" for validating height field? Thanks!


Though using regex to partially validate stuff is a good idea, you can't completely validate that sort of field with it. In particular you won't be able to catch such things like the inches value being greater than 11, for example.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!