[Logo]
Forums Register Login
String.split question
I'm trying to parse/split a String into tokens using the String.split( regex ) method, but I'm losing the empty tokens at the tail of the String. Currently, I'm using:

which creates the following String array:
str[0] = "1"
str[1] = "2"
str[3] = ""
str[4] = "4"
unfortunately, all the empty tokens are lost at the end of the String, but they need to be preserved.
Desired output:
str[0] = "1"
str[1] = "2"
str[3] = ""
str[4] = "4"
str[5] = "";
str[6] = "";
str[7] = "";
any suggestions?
Jamie
[ October 20, 2003: Message edited by: Jamie Robertson ]
[ October 20, 2003: Message edited by: Jamie Robertson ]
Try

You can look in the Java API doc for the "java.lang.String" class which provides a pretty good explanation between
split(String regex)
and
split(String regex, int limit)
[ October 20, 2003: Message edited by: Wayne L Johnson ]
thanks wayne, it works
I knew that method was there, but did not investigate it as I thought String.split( regex, [/b]limit[b] could only be applied as a limit(positive value).
Anyways, thanx for the quick response and insight,
Jamie
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Oct 19, 2017 02:11:23.