Hi.
I'm having a bit of trouble getting preg_replace to replace only subpattern match and not the whole string match.
I'm writing a script that reads an HTML file and replaces the contents of HTML tags like href="somefile.html"
with href="myscript.php?somefile.html"
I match the tag with:
$html_tag_pattern = "/<[\/!]?[<>]?(?:src|href|background)=\"?([\s\"])\"?[<>]?>/i";
in my understanding of PCRE, \0 is the whole tag, and \1 is the part inside the href="", <a href="\1">
I want to replace only \1, not \0 with a string I've put together.
Can I do this with a single preg_replace? How?
As a futher complication, as I do the above I need to ensure that I add quotes to any elements that are specified without quotes, i.e.: background=img.gif
Thanks in advance for any advice.
Eric