我获取一些 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
}