replace \n and \r\n with
in java

后端 未结 7 1477
余生分开走
余生分开走 2020-11-29 04:49

This has been asked several times for several languages but I can\'t get it to work. I have a string like this

String str = \"This is a string.\\nThis is a l         


        
7条回答
  •  隐瞒了意图╮
    2020-11-29 05:25

    A little more robust version of what you're attempting:

    str = str.replaceAll("(\r\n|\n\r|\r|\n)", "
    ");

提交回复
热议问题