Thanks leetcrew. I did mean preg_replace().
Which would be best to use in the following case - ereg_replace or preg_replace..
I have a form that is submitted containing html. Within the HTML are hyperlinks. I need to search through the html for the hyperlinks, and change them in the following way:
Original hyperlink: <a href="http://www.mywebserver.com/testpage.htm" target="_blank">Click</a>
New Hyperlink:
<a href="http://www.webserver.com/linkpage.php?e=$usn&id=$subj&red=$hyperlink (where $hyperlink is the original hyperlink)
On top of that, I obviously need to keep the target reference on the new URL.
I've tried using eregi_replace for this - my "code" (if you can call it that) is below...
$pattern = "(<a href=\"http://\")+[[:alnum:]][^>]$";
$translation = "<a href=\"http://www.webserver.com/linkpage.php?e=$usn&id=subj&red=$pattern\"";
$bodytext = eregi_replace($pattern,$translation,$bodytext);
Please bear in mind, this is the first time I've ever looked at preg_replace and ereg_replace...
If anyone could point out my mistakes here I'd be really grateful.
Thanks