This has been asked several times for several languages but I can\'t get it to work. I have a string like this
String str = \"This is a string.\\nThis is a l
It works for me.
public class Program { public static void main(String[] args) { String str = "This is a string.\nThis is a long string."; str = str.replaceAll("(\r\n|\n)", ""); System.out.println(str); } }
Result:
This is a string.This is a long string.
Your problem is somewhere else.