对于字符串
" \n a b c \n 1 2 3 \n x y z "
,我需要它变成"a b c 1 2 3 x y z"
。您可以使用以下正则表达式str.replaceAll("(\s|\n)", "")
得到"abc123xyz",但是如何在它们之间获得空格呢?