Reputation: 15006
I'm pulling in some data from an api and console.log in chrome:
Chrome prints it like asdföklajsd↵New line!
I would like to replace the ↵ character with a <br />
using replace
in javascript. How do I reference that character?
Upvotes: 25
Views: 25428
Reputation: 72857
It's a return character.
Try replacing them like this:
myString = myString.replace(/(\r\n|\n|\r)/gm, "<br />");
Upvotes: 47