嘿,我正在讀取.obj文件的行,我想加載他們到一些數組,但我需要正確解析它們。字符串陣列拆分沒有刪除
我讀一些線路是這樣的: ˚F19/19/115 25/25/116 17/22/117
,我想通過拆分他們爲「/」,但不刪除該字符,這是我想要得到的結果:
[f,19,/,19,/,115,25,/,25,/,116,17,/,22,/,117]
而我當我這樣做:
tokens = line.split("[/ ]+");
我越來越:
[f, 19, 19, 115, 25, 25, 116, 17, 22, 117]
https://docs.oracle.com/javase/7/d ocs/api/java/util/StringTokenizer.html#StringTokenizer%28java.lang.String,%20java.lang.String,%20boolean%29 – 2014-11-22 12:07:49
如果您嘗試'string1.replace(「/」,「#/」)。分裂(「#」);'? [同樣的例子](http://stackoverflow.com/questions/4416425/how-to-split-string-with-some-separator-but-without-removing-that-separator-in-j) – Milaci 2014-11-22 12:08:43
你可能會發現這個回答很有用:http://stackoverflow.com/questions/2206378/how-to-split-a-string-but-also-keep-the-delimiters。 – Iootu 2014-11-22 12:09:09