In essence I am trying to modify every token on a line that matches a criteria. I have a file with many lines and the the line can have many instances. Each line may or may not match. What I want to replace ar XML values, for example
<ns0:house>indifferent token</ns0:house> --> <ns0:house>xxx</ns0:house>
the token indifferent token will be replaced with xxx
It is not guaranteed that the XML be completed (it could be snippet) ...
Here is what I have
$output =~ s/(<.+house>)(.*)(\/.+house>)/$1xxx$3/g
I would read this as substitute, globally, all characters between and (I simplified the XMl element (but the .+ should account for any arbitrary namespace).
The resulting string has only some occurrence replaced. Logically in my head I know it has to do with the REGEX being greedy, but I cannot figure out how to fix it. I have pulled all my hair out trying to work around this.
I believe I have an alternative (more code) using split, but that is ugly.
Thought or suggestions welcomed.