Text cleaning and replacement: delete \n from a text in Java

后端 未结 9 1957
我在风中等你
我在风中等你 2020-12-08 19:57

I\'m cleaning an incoming text in my Java code. The text includes a lot of \"\\n\", but not as in a new line, but literally \"\\n\". I was using replaceAll() from the String

9条回答
  •  温柔的废话
    2020-12-08 20:38

    Normally \n works fine. Otherwise you can opt for multiple replaceAll statements. first apply one replaceAll on the text, and then reapply replaceAll again on the text. Should do what you are looking for.

提交回复
热议问题