I have a sample sed statement that I am running from the terminal that works just fine
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
echo '<body>
<p>This is some html with a link <a href=""http://anothersite.com/woot">http://anothersite.com/woot"><b>Restocked Traditional Items.</b></a></p>
<p>and</p>
<p>a link <a href=""http://anothersite.com/woot">http://anothersite.com/woot">over here</a></p>
</body>' | sed 's/\(<a href=""\)/\1 style="color:black"/g'
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
And when I run it I get the expected, and desired, results... The style="color:black" being added to both links.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<body>
<p>This is some html with a link <a href=""http://anothersite.com/woot">http://anothersite.com/woot" style="color:black"><b>Restocked Traditional Items.</b></a></p>
<p>and</p>
<p>a link <a href=""http://anothersite.com/woot">http://anothersite.com/woot" style="color:black">over here</a></p>
</body>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The problem though is when doing this in AppleScript. I wrote the following
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
set theHtml to "<body>
<p>This is some html with a link <a href="" href="http://anothersite.com/woot">http://anothersite.com/woot\"><b>Restocked Traditional Items.</b></a></p>
<p>and</p>
<p>a link <a href="" href="http://anothersite.com/woot">http://anothersite.com/woot\">over here</a></p>
</body>"
set theCommand to "echo '" & theHtml & "' | sed 's/\\(<a href="" style=\"color:black\"/g'"
set fixedHtml to do shell script theCommand
<body>
<p>This is some html with a link <a href=""http://anothersite.com/woot">http://anothersite.com/woot"><b>Restocked Traditional Items.</b></a></p>
<p>and</p>
<p>a link <a href=""http://anothersite.com/woot">http://anothersite.com/woot" style="color:black">over here</a></p>
</body>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------