A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
extracting numeric values from string
Joined: Dec 22, 2004
Dec 25, 2004 00:00:00
I have a
program that has a string.The
contains different numers(multi digit) and characters. I want to extract these numbers into different variables.
for eg. if the string is c 32 34.
Then I want to extract c, 32 & 34.
Please help me . Thanks in advance.
Joined: Mar 13, 2004
Dec 25, 2004 06:37:00
Pick off the fields with
if a field is a number, or whatever, you can use Integer.parseInt() inside a try/catch statement.
SCJP 1.4, SCWCD in process
Joined: Jan 29, 2003
Dec 25, 2004 12:09:00
If you're in JDK 5 play with Scanner. By default it will pull tokens off a string delimited by spaces (just what you need) and convert them to various types if possible.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
subject: extracting numeric values from string
How do I print a formatted number?
MessageFormat Help ?
regular expression question
Help! Question on converting String to BigInteger
AD LDS with DIGEST-MD5 can not connect
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013