while ((rec = br.readLine()) != null) {
Pattern pCells = Pattern
.compile("(\"[^\"]*(\"{2})*[^\"]*\")*[^,]*,");
Matcher mCells = pCells.matcher(rec);
System.out.println("mCells==============>"+mCells);
List<String> cells = new ArrayList<String>();//每行记录一个list
//读取每个单元格
while (mCells.find()) {
str = mCells.group();
str = str.replaceAll(
"(?sm)\"?([^\"]*(\"{2})*[^\"]*)\"?.*,", "$1");
str = str.replaceAll("(?sm)(\"(\"))", "$2");
cells.add(str);
}
listFile.add(cells);
}
我是用来读取文本中的数据的,
文本的行是这样的:
ip,status,roomid,mac,description
169.122.13.23,inactive,123,23:42:34:23:42:34,TT0读出来的却是这样的
ip,status,roomid,mac
169.122.13.23,inactive,123,23:42:34:23:42:34经过正则处理以后最后一列不见了 有木有。。正则表达式