I need a regular expression in javascript which does the following.
Those instances of a which are not the part of an HTML entity, should be replaced with w.
Ex:
abc should change to wbc
aabacaa should change to wwbwcww
&abcaa& should change to &wbcww&
and so on.
I am using JavaScript.
Any help is appreciated.
Try this:
"&abcaa&".replace(/&[^;]+;|a/g, function($0) {
return $0 === "a" ? "w" : $0;
})