I have a string with a bunch of values separated by a tilde and
greater than sign. So like.
String myList =
"123~>abv~>asdflkjasfdlkjslkdfjj~>asdflkj~>sldfkjsdlfkjadfs";
For simplicity sake to get me started, can someone share some code on
how I would loop through the myList values and output it to the screen
in the following format:
123
abv
asdflkjasfdlkjslkdfjj
asdflkj
sldfkjsdlfkjadfs
If there is a way to do this other than a loop I would prefer it be
looping through as I need to do some other stuff to each value as it
parses threw it.
Thanks.
JR
bencoe@gmail.com - 22 Jun 2007 05:27 GMT
> I have a string with a bunch of values separated by a tilde and
> greater than sign. So like.
[quoted text clipped - 19 lines]
>
> JR
String values[]=myList.split("->");
for(int i=0;i<values.length;i++)
System.out.println(values[i]);
hiwa - 22 Jun 2007 05:49 GMT
> I have a string with a bunch of values separated by a tilde and
> greater than sign. So like.
[quoted text clipped - 19 lines]
>
> JR
Use String.split() method.
JR - 23 Jun 2007 03:02 GMT
Thank you everyone for you input. Very helpful and much appreciated.
One note though, I am not so lucky as was mentioned. I do have a pipe
character in one of my situations it's "|~" without the quotes. Tried
using new char[] { '|' } from the Quoter site but could figure out how
to formulate: split("|~")
Thanks.
JR
> > I have a string with a bunch of values separated by a tilde and
> > greater than sign. So like.
[quoted text clipped - 23 lines]
>
> - Show quoted text -
JR - 23 Jun 2007 03:04 GMT
Got it, need to prefix the pipe with \\
Thanks again.
> Thank you everyone for you input. Very helpful and much appreciated.
> One note though, I am not so lucky as was mentioned. I do have a pipe
[quoted text clipped - 35 lines]
>
> - Show quoted text -
Lew - 23 Jun 2007 13:58 GMT
> Got it, need to prefix the pipe with \\
And to post replies inline with quoted text instead of top posting.

Signature
Lew
Roedy Green - 22 Jun 2007 06:20 GMT
>"123~>abv~>asdflkjasfdlkjslkdfjj~>asdflkj~>sldfkjsdlfkjadfs";
see Regex split http://mindprod.com/jgloss/regex.html
The string version of split will reparse and recompile the regex on
every use.
the following chars are reserved in Regex and need to be quoted:
$ ( ) * + - . < = ? [ \ ] ^ { | }
See http://mindprod.com/applets/quoter.html
You luck out in this case. Neither of ~> needs quoting.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com