I have an interesting string I want to properly break up into a string array. This string is as follows.
String test="?[32,120],x1y1,[object pieceP1],null]";
Now I have this regular expression to attack this.
String delims = "[?,\\[\\]]";
Now the results of splitting it using this code
String[] tokens = mapString.split(delims);
yields this result
–>
–>
32
120
–>
x1y1
–>
object pieceP1
–>
null
where the arrows are the empty lines.
How can I modify this regular expression so that there are no empty lines?
Thank you greatly in advance.
~ Selcuk
String delims = "[?,\\[\\]]+";// []+see the Greedy quantifiers part in Summary of regular-expression constructs of Pattern
but the leading empty element is still there.