function xx (string){ return string.replace(/( | | )/gm, "</br>"); } console.log('Here's some text. It has some line breaks that will be removed using Javascript. ');