I am currently working on a project in which the API will hide the description, which is formatted as follows:
IT'S ALSO This is a paragraph. This is another paragraph.
And the result I'm trying to get is
IT'S THE SAME
This is a paragraph.
This is another paragraph.
I played with some regular expressions, but struggled to get the desired result, my current attempt is to add a line break at the end of each top-level letter / word.
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(",");
Is it possible to get the desired result? (jsfiddle example: https://jsfiddle.net/srwwpxh4/1/ )
source
share