I am reading an XML file in which I am replacing certain words. I don't want to replace words that come in XML elements or attributes. I'm using negative look behind and look ahead and I'm 90% there. However, if a value comes in an attribute that contains the string which I want to replace then it is getting replaced. I don't want that.
My regex:
-$fi=~s/(?<!<|\/)(?<!value=")\bis\b(?!=)/iss/g
This regex does not match elements attributes and value attributes. But if there is a text like value="hello there"
and I am replacing there
with some word then it is getting replaced. I want a regex that will search if the word there
is not preceded at the start of value="
.