I have a string like this:
BEGIN\n\n\n\nTHIS IS A STRING\n\nEND
And I want to remove all the new line characters and have the result as :
BEGIN THIS IS A STRING END
How do i accomplish this? The standard API functions will not work because of the escape sequence in my experience.
A simple
replace('\n', ' ')will cause the string to become:where the
*‘s are spaces. If you want single spaces, tryreplaceAll("[\r\n]{2,}", " ")And in case they’re no line breaks but literal
"\n"‘s wither try:or: