我使用的是Java 1.7版 我有一个字符串:
String customerList="'C1','C2','C3','C4','C5'";
我想将每个客户解析为单独的字符串,例如
字符串C1,C2,C3,C4和C5
我该怎么做?
答案 0 :(得分:3)
例如:
String customerList="'C1','C2','C3','C4','C5'";
for( String s : customerList.split(",") ) {
System.out.println(s.replaceAll("'", ""));
}
答案 1 :(得分:1)
String customerList="'C1','C2','C3','C4','C5'";
String[] a = customerList.replace("'", "").split(",");
现在a
暂停Strings
"C1", "C2"
等...
测试:
for(String x : a)
System.out.print(x + " ");
将打印C1 C2 C3 C4 C5