My question is based on the great answer from this SO question How to encode a string in JavaScript for displaying in HTML?
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
I need the same but should keep each "<br>"
substring in the string. Looking for the best way to modify the function htmlEntities
then.
Thank you.
" occurencees with "<br>" but I should keep all "
" in the string. – Haradzieniec Sep 26 '14 at 17:25
")` on the end ? – adeneo Sep 26 '14 at 17:25