2015-10-19 108 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