Java Regex remove new lines, but keep spaces.

Viewed 36905

For the string " \n a b c \n 1 2 3 \n x y z " I need it to become "a b c 1 2 3 x y z".

Using this regex str.replaceAll("(\s|\n)", ""); I can get "abc123xyz", but how can I get spaces in between.

5 Answers
Related