Using the jQuery text function I received a string that contains a lot of carriage returns/line breaks in sequence.
For example, “\r\n \r\n \r\n Welcome Bob\r\n\t \r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Recommendation: Hellot\r\n\r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n” .
Is it possible to have just one line break instead of a sequence using JavaScript, presumably replace function?
Use
to match any whitespaces around your carriage returns/linebreaks and replace them by
\naltogether.