How to remove the \n, \t and spaces between the strings in java?

前端 未结 2 489
鱼传尺愫
鱼传尺愫 2020-12-21 10:08

How do you remove the \\n, \\t and spaces between strings in java?

2条回答
  •  抹茶落季
    2020-12-21 10:26

    str.replaceAll("\\s+", "");
    

    \s A whitespace character: [ \t\n\x0B\f\r]

    java.util.regex.Pattern has all the predefined classes.

提交回复
热议问题