-4

How can I remove or replace \r in javascript text or in backend code in C# I have a variable in javascript like this:

var text="name\rhi\r"

\r means line break or next line

I try to this approach to replace:

text=text.replace("\r",",");

but does not work

Ali Besharati
  • 918
  • 12
  • 25

2 Answers2

2

Typically in JS, using replace("/r",",") only replaces the first thing it finds, try using replace(/\/r/g,",")

Jason T
  • 23
  • 4
1

In C# Replace will work:

        string source = "\rhi\ryou";
        string result = source.Replace("\r", "");
MikeJ
  • 1,299
  • 7
  • 10