2014-09-10 102 views
-3

我使用的Java版本1.7 WHERE子句字符串我有一个字符串:解析Java中

String customerList="'C1','C2','C3','C4','C5'"; 

我想每一个客户解析成单独的字符串,如

字符串C1,C2, C3,C4和C5

我该怎么做?

+0

String [] customers = customerList.splitString(“,”); – StackFlowed 2014-09-10 20:08:40

+0

'split()'和'replace()' – 2014-09-10 20:08:45

回答

3

例如:

String customerList="'C1','C2','C3','C4','C5'"; 
for(String s : customerList.split(",")) { 
    System.out.println(s.replaceAll("'", "")); 
} 
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