【发布时间】:2020-12-03 03:37:07
【问题描述】:
我想从给定的字符串格式中删除新行
This is test;
This is new test;
This is new test2;
This is another string test;
this is more space string test;
输出应该是这样的:
This is test;
This is new test;
This is new test2;
This is another string test;
this is more space string test;
我知道我可以使用正则表达式或全部替换为“\n” 但在这种情况下,所有字符串都将被替换为单行,并且我想要的字符串顺序不会被维护。?
【问题讨论】:
-
我发布这个问题是为了避免暴力破解,因为我的实际文件为 1 MB,如果有任何具体方法,我需要知道
标签: java string replace removing-whitespace