if anybody's wondering, I fixed it with the following expression:
1 while s/&(?=[\w&]+<\/link>)/&/g;
if you want to see it in action, just run the following script:
Code:
#!/usr/bin/perl
$_="<title>foo&bar</title><link>but&thisand&this</link><link>foo&barfsfoo&badrffoo&basrfoo&bar</link><link>booo&thisand&this</link>";
print "$_\n";
1 while s/&(?=[\w&]+<\/link>)/&/g;
print "$_\n";
christo