| Author |
How to parse a string with "|" and empty strings
|
Rajani Gummadi
Ranch Hand
Joined: Dec 17, 2010
Posts: 48
|
|
Hi All,
I'm trying to parse a String like A|B|C|D||||| as follows
My expectation is as follows
Token = A
Token = B
Token = C
Token = D
Token =
Token =
But I get only first 4, obviously the last 2 are not considered or ignored... I knew that my regular expression is wrong, but could not figure out the solution on how to have the emply strings surrounded by "|" is also retrieved..
Can some body help me in this ?
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
|
Use the form of "split" that takes a second int parameter; pass Integer.MAX_VALUE as the argument when you call it. The empty substrings will be returned.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Rajani Gummadi
Ranch Hand
Joined: Dec 17, 2010
Posts: 48
|
|
|
Thank you.
|
 |
 |
|
|
subject: How to parse a string with "|" and empty strings
|
|
|