\r\n\r\n.... replace with single \r\n in javascript code example Example: javascript replace \n var r = "I\nam\nhere"; var s = r.replace(/\n/g,' ');