How do i write a regex to replace
or
with \\n
. I\'m trying to move text from div to textarea, but don\'t want
var str = document.getElementById('mydiv').innerHTML;
document.getElementById('mytextarea').innerHTML = str.replace(/
/gi, "\n");
or using jQuery:
var str = $("#mydiv").html();
var regex = /
/gi;
$("#mydiv").html(str.replace(regex, "\n"));
example
edit: added i
flag
edit2: you can use /
which will match anything between the
]*>/gibr
and slash
if you have for example