我有這個字符串Java字符串分割給人意想不到的結果
String x = "2013-04-17T08:00:00.001,41.14806,-9.58972,-13.0,0.0,0.0,-20.0,4|2013-04-17T08:00:00.001,41.14806,-9.58972,-22.0,0.0,0.0,-20.0,4|2013-04-17T08:00:00.001,41.14806,-9.58972,-31.0,0.0,0.0,-20.0,4|2013-04-17T08:00:00.001,41.14806,-9.58972,-40.0,0.0,0.0,-20.0,4|2013-04-17T08:00:00.001,41.14806,-9.58972,-49.0,0.0,0.0,-20.0,4|2013-04-17T08:00:00.001,41.14806,-9.58972,-58.0,0.0,0.0,-20.0,4|2013-04-17T08:00:00.001,41.14806,-9.58972,-64.0,0.0,0.0,-20.0,4";
如果我做分裂這樣String vec2 [] = x.split(",");
輸出將是這個
2013-04-17T08:00:00.001
41.14806
-9.58972
-13.0
0.0
0.0
-20.0
等。
如果我做這樣String vec2[] = x.split("|");
輸出分割是這樣的:
2
0
1
3
-
0
4
-
1
7
T
0
8
:
0
0
:
等。
而且我希望類似這樣的東西:
2013-04-17T08:00:00.001,41.14806,-9.58972,-13.0,0.0,0.0,-20.0,4
2013-04-17T08:00:00.001,41.14806,-9.58972,-22.0,0.0,0.0,-20.0,4
and so on
任何想法有什麼不對?
http://stackoverflow.com/questions/1433115/what-is-the-proper-way-of-inserting-的可能重複a-pipe-into-a-java-pattern-expression – Ankit
'String ** vec2 []'在Java中是無效標識符! – NINCOMPOOP
@NoobUnChained我認爲這是因爲他想讓它變成粗體。 – Maroun