Remove all line breaks from string

Copy this small function bellow to your code:

function removeLineBreak(string) {
    return string.replace(/\r?\n|\r/g, '');
}


Usage:

const stringLineBreak = 'textxxx1\ntextxxx2\ntextxxx3';
const stringwithoutLineBreak = removeLineBreak(stringLineBreak);
// stringwithoutLineBreak = 'textxxx1textxxx2textxxx3


© 2019 4codev

Created with love by Sil.