【发布时间】:2011-09-02 21:15:09
【问题描述】:
我获取一些 html 并进行一些字符串操作,然后得到一个类似的字符串
string sample = "\n \n 2 \n \n \ndl. \n \n \n flour\n\n \n 4 \n \n cups of \n\nsugar\n"
我想查找所有成分行并删除空格和换行符
2 分升。面粉和4杯糖
到目前为止,我的方法如下。
Pattern p = Pattern.compile("[\\d]+[\\s\\w\\.]+");
Matcher m = p.matcher(Result);
while(m.find()) {
// This is where i need help to remove those pesky whitespaces
}
【问题讨论】:
标签: java regex string removing-whitespace