• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String parse

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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









 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic