File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes String parse Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "String parse" Watch "String parse" New topic
Author

String parse

anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133
hi all,

I have a string like below



String a; int count;

How would I parse the string "F9,D8,R7,Q0..."?

I want to parse the string like below.

....so on.

Thanks









fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9948
    
    6

write down how you'd tell me to do the same thing, in english. That is the hard part. Giving an example isn't enough. You need to spell out step by step how it should be handled, and what assumptions you are making.

Is the pattern always "letter, digit, comma" repeated some number of times? is the ellipses actually in your string, or is that just to illustrate? Can you have two letters before a number, and what does that mean?

There are other issues, but this should get you started.


Never ascribe to malice that which can be adequately explained by stupidity.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Look at String.split() to split into strings between the commas. Depending on the complexity of your Strings after that, you could use String.substring() or look at java.util.regex.Pattern and java.util.regex.Matcher
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: String parse
 
Similar Threads
variable problem
using new in the main method
FileNotFoundException is thrown when i try to read a file?
Intra Ranch Go Game!
poll(),peek() in PriorityQueue class