This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help me on String Validation  RSS feed

 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, i have a string variable that to store name. How i can validate whether it is logic name or not? I mean logic name is, a person name not suppose have number or symbol with it.

Eg.
"Mike"---> valid,
"Mik3"---> not valid,
"01_Mike"---> not valid.

Thanks in advance.
 
Deeps Dhr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to apply the javascript validation for checking the same?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do this different ways. Have a look at the toCharArray() method of the String class, and the static isLetter(char ch) method of the Character class. Alternatively, if you are comfortable with regular expressions, look at the java.util.regex package.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!