我有一个下面提到的 RawString
"Link\">https:\/\/tsad.rs\/2RBWI5E\n\n By Tom Westbrook\n sjda, asd 14 (sda) - sad dsad asd lower on\nTuesday, but gains in riskier currencies were capped as traders\nfretted adlaj \nladsadj \n Available to our procedure.JPY=
only one thing need to fix in this, where i am getting "\n" with space that mentioned below.
\n By Tom WestbrookText after "\n" with space want to show in Next line remove this "\n" but where i am getting only \n like below.
on\nTuesday,i want to add null String like "". How can i achieve this. i am using like this but not getting proper result.
sentences[i] = sentences[i].replaceAll("\\n ", "");
sentences[i] = sentences[i].replaceAll("\\n", "");
最佳答案
您可以在 java 中使用以下代码 fragment 来获得所需的输出。
String str = s.replaceAll("\\\\n", "~")
.replaceAll("~\\s", System.lineSeparator())
.replaceAll("~", "");
关于java - 如何将 "\n "替换为新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61200609/