0

I was trying to replace \n by \\n in a string in typescript. As i wanted to replace all occurrences, the best option was to use a regex expression. suppose

let str="\n\nSimply tap or right click on these links";
str.replace(new RegExp('\n','gi'), '\\n');

But this does not work. Can someone explain why?

anubhava
  • 761,203
  • 64
  • 569
  • 643

0 Answers0