I am currently working on a project where the API spits a description that is formatted like this:
THIS IS A TITLE This is a paragraph. This is another paragraph.
THIS IS A TITLE
This is a paragraph
This is another paragraph
var myString = "THIS IS A TITLE This is a paragraph of random text. This is another paragraph of random text.";
var myStringFormatted = myString.replace(/([A-Z]+)/g, ",$1").replace(/,/g," <br />").split(",");
You could use a positive lookahead.
It looks for a non word character first, upper case character followed by a lower case character and insert a line feed before.
var r = /\W+(?=[A-Z][a-z])/g, s = 'THIS IS A TITLE This is a paraGraph. This is another paragraph.'; console.log(s.replace(r, '$&\n'));