2014-09-10 3 views
-3

에서 WHERE 절 문자열을 구문 분석 내가 문자열을 가지고 :내가 자바 버전 1.7 을 사용하고 자바

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

내가

문자열 C1, C2처럼 개별 문자열로 각 고객을 구문 분석하고 싶습니다, C3, C4 및 C5

어떻게해야합니까? 예를 들어

+0

String [] customers = customerList.splitString (","); – StackFlowed

+0

'split()'과'replace()' –

답변

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

관련 문제