Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

to find and retrieve a number in a string  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me how to find and retrieve a number in string.

For eg,
in "emp1_fname" i should retrieve "1" from that string....how it is possible.If i use string tokenizer will it be possible?Reply ASAP
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far ?

Have a look at String.substring, String.split, java.util.regexp....

Please reply ASAP.

pascal
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one of the easy way to to do is :
First convert the string to char array and then read each character and match that with 0 to 9 and print.


if not statisfied then reply back ASAP.
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!