How to remove all line breaks from a string using JavaScript?

Hello friends, today I will tell you through experts php tutorial how you can remove all line breaks from a string using JavaScript. So let’s try to understand step to step with example.

remove-line.html

var stringWithLineBreaks = '
I've got 
Breaks
';
var stringWithoutLineBreaks = stringWithLineBreaks.replace(/(\r\n|\n|\r)/gm, "");//remove those line breaks