I have a html entities replacement for & that look like this:
function htmlEntities(str) {
return String(str).replace(/&(?!amp;)/g, '&');
}
which are working fine that not to replace the &
but will replace &
how do I add multiple condition to regex of my function so that it will not mess with other html entities like:
'
"
>
<
i test with:
var xxx = "1234 &aaa& aaadas 'xxx' \" kkk <aasd> xxxxxxxxxxxxxxxx <";
console.log(htmlEntities(xxx));
it will replace the <
to become &lt;
and this is not what I want, i need it to leave the <
untouch just like the example &aaa&
to become &aaa&
hope you get what I mean, any idea?