I have a string and would like to simply replace all of the newlines in it with the string " --linebreak-- "
.
Would it be enough to just write:
string = string.replaceAll("
", " --linebreak-- ");
I'm confused with the regex part of it. Do I need two slashes for the newline? Is this good enough?
question from:https://stackoverflow.com/questions/9849015/java-regex-using-strings-replaceall-method-to-replace-newlines