I have a function that replaces HTML entities for & to avoid replacing & but it still changes other entities like &, ", >, and <.
How can I modify the regex in my function to exclude these specific entities?
'
"
>
<
I tested with:
var xxx = "1234 &aaa& aaadas 'xxx' \" kkk <aasd> xxxxxxxxxxxxxxxx <";
console.log(htmlEntities(xxx));
The current function turns <
into &lt;
which is not the desired outcome. It should only convert instances like &aaa&
to &aaa&
.
If you understand my problem, please share any solutions you may have. Thank you!