I'm trying to obtain the values of a String, which is separated by commas.
something like this: String str = "item1, item2,0 item3, item4, 0 item5 ...."
This strange String it's because I have a KML that I take the coordinates of a polygon parsing the kml. Example:
<coordinates>
2.18954459419779,41.40492402705473,0 2.189651379989959,41.40491712193686,0 2.189993453581252,41.40464878075789, ....
What i done to separate it, is:
List<String> items = Arrays.asList(str.split("\\s*,\\s*"));
But I don't know how to make that this 0 disappears o put a comma between the 0 and the next number.
How can I do it?
Edit: Solution
Testing the answers, what it works perfect to my problem is this solution:
String[] str_solution = str.split("\\s*,0?\\s*");