javascript replace \n

JavaScript
var r = "I\nam\nhere";
var s = r.replace(/\n/g,' ');
Source

Also in JavaScript: