I'm doing some string replacement on text I'm getting back from a JSON web service, the string may look like this:
"Hello I am a string.\r\nThis is a second line.\r\n\r\nThis is a bigger space"
I want to replace all the \r\n
with <br />
tags so that the HTML is formatted, but when I do:
var string = result.replace('\r\n','<br />');
I only get the first instance replaced, not any other.
What am I doing wrong?