Mr.Easy Answers McFly Mr.Easy Answers McFly - 9 months ago 72
Javascript Question

Regex for \n not working

let text= "PLEASE UPDATE WITH NEW ZSP\n- Areas with significant";

let regex = "/\n/g";

text = text.replace(regex, "<br/>")

As you can see I'm trying to convert text with a regex and it still returns the same text including


RegExp literals in JavaScript are objects, not strings - lose the quotes around your pattern.

let regex = /\n/g;