I'm ashamed but i'm too stupid to learn regexp properly.
I'd like to remove all the links from html, but leave the text, underlined.
I need to replace all "<A HREF_anything_until_>" with <U> with regexp i hope someone can provide.
The closing </a> i can replace with str_replace.
Regexp whining
Moderator: General Moderators
the following code i got from this forum.. so you should be able to find it too....
http://www.regularexpressions.info/
http://www.samuelfullman.com/team/php/t ... ster_p.php
Code: Select all
$url = 'http://cnn.com';
$document = @file_get_contents($url);
preg_match_all('/<a(.*?)>(.*?)<\/a>/i', $document, $matches);
print_r($matches);http://www.samuelfullman.com/team/php/t ... ster_p.php
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
Thanks. Made this from the above.
Code: Select all
function links_off($buffer)
{
// Poista Linkit
$a = preg_replace("/<a(.*?)>/i", "<U>", $buffer);
$a = preg_replace("/<\/a>/i", "</U>", $a);
return $a;
}