[英]Transform a [string,string] to Array
Hello everybody I have this string: 大家好,我有这个字串:
[JOLLY BLU at STAY SHIP, Voy: 0275/11]
How I can turn this string in a String[] 如何将这个字符串转换为String []
value[0] = "JOLLY BLU at STAY SHIP";
value[1] = "Voy: 0275/11";
Thankyou much 非常感谢
str = str.substring(1, str.length() - 1); // cut [ and ] off
String[] parts = str.split(",");
String s = "[JOLLY BLU at STAY SHIP, Voy: 0275/11]";
String temp = s.replace("[", "").replace("]", "");
// or String temp = s.substring(1, s.length() - 1);
String[] sArray = temp.split(",");
sArray[1] = sArray[1].trim(); // remove the whitespaces around the string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.