I've spent most of the day trying to solve this problem, and much
searching has also failed to find a solution! I wonder if anyone can
suggest a solution?
Basically I need to rewrite all *internal* links on a page to add a
query string to each. For instance,
<a href="/path/to/file.html" target="_blank">
should become
<a href="/path/to/file.html?edit" target="_blank">
and
<a href="" target="_blank">
should become
<a href="?edit" target="_blank">
but
<a href="http://example.com/path/to/file.html" target="_blank">
should stay unchanged.
I've tried things like:
$search = '(<a([^>]*) href="(?<!http://)([^"]*)"';
$html = preg_replace ("~{$regexp}~i", '\1?edit', $html);
but the presence of the [^"]* seems to make the negative look-behind
assertion fail.
Any ideas gratefully received!