javascript remove line breaks from string

JavaScript
var stringWithLineBreaks = `
O boy 
I've got 
Breaks
`;
var stringWithoutLineBreaks = stringWithLineBreaks.replace(/(\r\n|\n|\r)/gm, "");//remove those line breaks// regex global match for all variants of newlines
/\r?\n|\r/g

// example
let foo = 'bar\nbar';
foo = foo.replace(/\r?\n|\r/g, " "); /* replace all newlines with a space */
console.log(foo); /* bar bar */String.replace(/(\r\n|\n|\r)/gm," ")
Source

Also in JavaScript: