字符串拆分问题
有如下字符串(FL_M1-MF-SRS-02|FL_M1-MF-SRS-03)&FL_M1-MF-GT-02&FL_M1-MF-SJQ-01
要把它拆分成数组 (,FL_M1-MF-SRS-02,|,FL_M1-MF-SRS-03,),&,FL_M1-MF-GT-02,&,FL_M1-MF-SJQ-01
这几个特殊字符有可能3个连续出现
我写到这写不下去了
package com.excel.common;
import java.io.*;
import jxl.*;
import jxl.read.*;
import jxl.read.biff.BiffException;
import jxl.write.*;
import java.util.*;
public class ModifyExcle {
public static void main(String[] args) {
try {
Workbook wb = Workbook.getWorkbook(new File("c:\\test.xls"));
Sheet sheet = wb.getSheet(0);
Cell cell1 = sheet.getCell(0, 0);
String result = cell1.getContents();
String res = result.replaceAll(" ", "");
System.out.println(res);
char[] str = { '(', ')', '!', '&', '|' };
ArrayList al =new ArrayList();
for (int i = 0; i < res.length(); i++) {
for (int j = 0; j < str.length; j++) {
if (res.charAt(i) == str[j]) {
al.add(i);
}
}
}
for(int i=0;i<al.size();i++)
{
}
System.out.println(res.substring(0, 0));
} catch (BiffException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
请大家帮忙 谢谢