我有以下的样本数据:的Java通过拆分字符串 “^ | ^”
***^|^100^|^101^|^102^|^103^|^104^|^
我希望通过拆分 “^ | ^” 这样的结果将是:
***
100
101
102
103
104
以下是我的示例代码,但未能获得预期的结果,我误解了分割模式?
String a = "***^|^100^|^101^|^102^|^103^|^104^|^105^|^106^|^107^|^108^|^";
String [] split ;
split = a.split("^|^");
for(int i=0; i<split.length; i++)
{
System.out.println(split[i]);
}
'分= a.split(“\\ \\^| \ \ ^“);'使用此 –
http://stackoverflow.com/questions/21524642/splitting-string-with-pipe-character –