Posted By: Anonymous
<br /> elements?
A variable passed from PHP as below:
"This is man. Man like dog. Man like to drink. Man is the king."
"This is man<br /><br />Man like dog.<br />Man like to drink.<br /><br />Man is the king."
This will turn all returns into HTML
str = str.replace(/(?:rn|r|n)/g, '<br>');
In case you wonder what ?: means.
It is called a non-capturing group. It means that group of regex within the parentheses won’t be saved in memory to be referenced later.
You can check out these threads for more information: