0

I am using this call to remove carriage returns from a String

input = input.replaceAll("[\r\n]", "");
return input;

But when given this String as input: http://localhost:4200/\n\rhome

I get the following output: http://localhost:4200/\\n\\rhome

Any idea why? And how can I fix this?

lzdyzydy
  • 69
  • 1
  • 9
  • 2
    Probably, your input string has no line breaks at all, try `input.replaceAll("\\\\[rn]", "");` – Wiktor Stribiżew Jun 12 '20 at 16:19
  • cant get optuput as say. usually tell regex control code notation `"[\\r\\n]"` not the actual code as translated by java. `"[\r\n]"` –  Jun 12 '20 at 16:29

0 Answers0