• Post Reply Bookmark Topic Watch Topic
  • New Topic

Chunk string into pieces  RSS feed

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

i have a list of

String Z= "1c0e0146726565326d6f7665205755001e0c0153657269616c506f72740041120146324d30334758412d5330312d52324300400d01000900000000000004030000420701000bce0cb021";

how can i seperate it into the follwing chunks

String A="1c0e0146726565326d6f766520575500"
String B="1e0c0153657269616c506f727400"
String C="41120146324d30334758412d5330312d52324300"
String D="400d01000900000000000004030000"
String E="420701000bce0cb021"


*Note*
Example for this string "1c0e0146726565326d6f766520575500"
-there are some characteristic on these String.
-for String position at 3 & 4, it show the length(in hexadecimal) of the following character. Example "0e" = 14 in decimal
-for String position at 5 & 6, it will be "01"


Please help. Thanks in advanced.
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand how you determine where to break apart the string.

An example is great, but it isn't what you need in order to write code. You need to spell out in very simple terms what the criteria is for breaking the string. Is it a number of characters? Is there some identifier in the string itself?
 
Jeansonne Pierre
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Opps sorry,

Some add on.

*Note*
Example for this string "1c0e0146726565326d6f766520575500"
-there are some characteristic on these String.
-for String position at 1 & 2, it will be fixed. "1c", and for other example "1e","41","40","42"
-for String position at 3 & 4, it show the length(in hexadecimal) of the following character. Example "0e" = 14 in decimal
-for String position at 5 & 6, it will be "01"
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't help. when you say "it will be fixed" - WHAT will be fixed? Are you saying "it will be a fixed length"?

Programming is really 90% thinking. You need to have a clear, precise, and accurate description of what you want done. Pretend you are explaining to a small child what needs to be done. Simple, clear, precise directions are required.

I am guessing you will probably need to make use of the "substring(int beginIndex, int endIndex)" method. Be sure to read the API so you understand what exactly you should pass it to get the chunk you want.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!