[Javascript] How to remove line breaks from the given string?
I want to remove all the line breaks from a given string, How can I do that in Javascript?
1 Answer
4 years ago by Jahaan
You can use any of the below methods to remove line breaks from the given string.
Method 1
string.replace(/(\r\n|\n|\r)/gm, '')
Method 2
string.split('\n').join('')
Apply the above methods online here https://onecompiler.com/javascript/3xnrwad4y
4 years ago by Meera