2015-10-19 102 views
-8
String string = "[A100, test, message1, 6/24/2015 19:38, 6/24/2015 19:38], 
[A101, test, message2, 6/24/2015 19:38, 6/24/2015 19:38], 
[A102, test, message3, 6/24/2015 19:38, 6/24/2015 19:38], 
[A103, test, message4, 6/24/2015 19:38, 6/24/2015 19:38]" 

I want split as four parts 
A101, test, message2, 6/24/2015 19:38, 6/24/2015 19:38 
A101, test, message2, 6/24/2015 19:38, 6/24/2015 19:38 
A102, test, message3, 6/24/2015 19:38, 6/24/2015 19:38 
A103, test, message4, 6/24/2015 19:38, 6/24/2015 19:38 

請問您能否儘快完成。拆分複雜字符串中的字符串部分

List<String> elephantList = Arrays.asList(incomingString.split("],")); 
     for (String string1 : elephantList) { 
      if(string1.contains("Intro to Working with the IACUC") ||string1.contains("Working with the IACUC")){ 
+3

_can請您儘快possible_歡迎'SO'做。請描述您的代碼並解釋您遇到的問題 – Reimeus

+3

請修復您的格式,指定您的問題,並且由於您在此處不支付任何人,我們不會「儘快」執行任何操作。 – Thargor

回答

0

看看這有助於U:

String string = "[A100, test, message1, 6/24/2015 19:38, 6/24/2015 19:38],[A101, test, message2, 6/24/2015 19:38, 6/24/2015 19:38], [A102, test, message3, 6/24/2015 19:38, 6/24/2015 19:38],[A103, test, message4, 6/24/2015 19:38, 6/24/2015 19:38]"; 

String [] s1=string.split("\\],"); 
for(String s : s1) 
{ 
System.out.println(s.replaceAll("[ \\[\\] ]", "")); 
} 

輸出:

A100, test, message1, 6/24/2015 19:38, 6/24/2015 19:38 
A101, test, message2, 6/24/2015 19:38, 6/24/2015 19:38 
A102, test, message3, 6/24/2015 19:38, 6/24/2015 19:38 
A103, test, message4, 6/24/2015 19:38, 6/24/2015 19:38