Split Function in Angular for a certain combination

You can replace \r\n with something else, then split by \n and put back the replaced \r\n:

'Hello\r\nand World 15.6\n3'.replaceAll('\r\n', '&newline').split('\n').map(item => item.replaceAll('&newline', '\\r\\n'))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top