I'm having trouble getting my line breaks to show up in a textarea. The data I'm receiving contains double backslashes on line breaks (i.e., \\n ). I've tried using regular expressions to remove one of the backslashes before setting the value of the textarea--not working.
Here's a re-creation of the problem: http://jsfiddle.net/xkM23/3/
Does anyone know how to get the line breaks to show up properly in that textarea?
You have to escape \ for JavaScript (and make them double \\). Then it's working as intended: http://jsfiddle.net/xkM23/6/
.replace(/(\\r)|(\\n)/g,"\n")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With