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经过正则处理以后最后一列不见了 有木有。。正则表达式
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经过正则处理以后最后一列不见了 有木有。。正则表达式
解决方案 »
- 关于JAVAREPORT打印功能
- jsp的问题
- 这样的 webservices 接口 如何可以用SOAP 协议调用
- 如何去掉页面中的缓存?
- 希望大家帮我看看怎样改这个程序,谢谢!
- jsp中如何把表单提交到邮箱
- 请教 jsp 数组的问题
- 帮帮我看看俺的代码的问题,解决问题50分相送。
- ◆◆◆◆这是怎么问题???我直接在浏览器地址栏输入这个URL,它能查询,但我用这个JSP可是不行啊,为什么????
- 菜鸟级问题,如何把变量安全的放在内存中,在线等待--急
- websphere 7 连接池不释放
- 在JSP中,想实现把自己的用户名和密码在实现页面跳转后自动填写到一个别的网站的登录框中,请问怎么实现,请大侠指点,谢谢
.compile("(\"[^\"]*(\"{2})*[^\"]*\")*[^,]*,");去掉最后的逗号。
去掉“,"后 结果如今下[[ip, , status, , roomid, , mac, , description, ], [169.122.13.23, , inactive, , 123, , 23:42:34:23:42:34, , TT0, ]]又多出一个逗号 蛋疼