Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

identify data type in string?

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ...

I got a string related quesiton .........

if i have a string ="sdfdsdssdfsd34324efgegdf"

and i have to make sure that this will not contain any numeric values...number should not be there or only number required then in such case how am I provie type safty to string ...........

Thanks
Kaustubh
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you want to check whether a string contains (or doesn't contain) numbers? You can do that in multiple ways, one of them being through Java regex Pattern
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The other way is to go trough the whole string and look for digits.

>
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Friends
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic