Original
There is no reason for \
.
var destination = source.replace(/b/g,"<br/>");
JsFiddle example
Edit
Now you have provided a sample script with this code
function gettext(){ var input = document.getElementById("input").value; var value = input.replace("/b/g","<br/>"); var output = document.getElementById("out").value = value; }
Look at the replacement string
var value = input.replace("/b/g","<br/>");
this is a non-regex string
"/b/g"
It should be
var value = input.replace(/b/g,"<br/>");
JsFiddle example with code
source share