This is more a puzzle question for my curiosity than anything else. I'm looking for a single regular expression substitution that will convert entity escaped ampersands to an unescaped ampersands only within href attributes in an html file. For example:
<a href="http://example.com/index.html?foo=bar&amp;baz=qux&amp;frotz=frobnitz">
Me, myself & I</a>
Would convert to:
<a href="http://example.com/index.html?foo=bar&baz=qux&frotz=frobnitz">
Me, myself & I</a>
Now, I can do this in several statements but I'm curious if any perl regex gurus can do it in one.
The closest I've come so far is the following regex that doesn't work because lookbehinds can't be of variable length. Of course, it might not work even if they were allowed, I'm not sure.
s/(?<=href=".*?)&(?=.*?")/&/g;
Thanks.