Replace new line character in textArea field in Apex
It depends on which character is used (that differs between operating systems). If you use these three (make sure the \r\n
one is first) it should work:
street = street.replace('\r\n', ' ');
street = street.replace('\n', ' ');
street = street.replace('\r', ' ');
Same answer as rael_kid, but in one regex:
replaceAll('\r\n|\n|\r',' ');
I dont know previously it was supported or not, but now best way to achieve it is:
street = street.unescapeJava();