| Author |
StringTokenizer - why does it take [|] and [] as the same?
|
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
I'm writing to code to tokenise this string String theString = "123@star.com[|]lsep@mail.com,00887217904202[&]mmey@mail.com,00884457850456[&]00882131420000@star.com,[|]False[|][|]31/05/2004 08:48:43[|][|]" StringTokenizer st = new StringTokenizer(theString, "[|]"); When I read it I get; (I'm counting the tokens at the start of the line) 8 123@satstar.com 7 lsep@mail.com,00887217904202 6 & 5 mmey@mail.com,00884457850456 4 & 3 00882131420000@satstar.com, 2 False 1 31/05/2004 08:48:43 The question is, why do the &'s next to 6 and 4 appear? And I am only expecting 6 tokens. Can anyone give some advice? Thanks, Rachel
|
 |
bart zagers
Ranch Hand
Joined: Feb 05, 2003
Posts: 234
|
|
Hi, the "problem" is that the constructor does not work as you assume.
The tokenizer does not use "[|]" as a delimiter, but each occurrence of any of the characters in the string, "[" or "|" or "]" Bart
|
 |
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
Well, I guess that makes sense... Thanks!
|
 |
 |
|
|
subject: StringTokenizer - why does it take [|] and [] as the same?
|
|
|