I've inherited a database full of articles, all of which contain enormous links which use the URL as the target, eg:
<a href="http://www.longurlgoeshere.com">http://www.longurlgoeshere.com</a>
I'd like to write a regex to just rename these to 'click here' or something - I took this code from the PHP manual:
Code: Select all
$content = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
"<a href=\"\\0\">\\0</a>", $content);
<a href="%3Ca%20href=" http:="" http://www.website.com="" portal="" server.pt="" gateway="" ptargs_32_0_1851_0_-1_47="" http;="" i-collab.website.com;7001="" collab="" do="" document="" overview?projid="881618&folderID=872457"">FULL URL GOES HERE</a>"> <a href="FULL URL GOES HERE">FULL URL GOES HERE</a>
so I sort of end up with 2 links. I tried modifying the regex like so:
Code: Select all
$content = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
"<a href=\"\\0\">Click Here</a>", $content);
Cheers
Matt