Just The Code Please

How to remove new lines from text in Javascript

January 9th 2024

Summary

From time to time we need to manipulate text in the browser. It's common to work with text that contains new lines. Sometimes this isn't ideal, and we need to remove them. This is how you do it!

The Code

Javascript
someString = someString.replace(/[\n\r]/g, '');