Hallo, I have a small preblem: I want to strip some <A> tags from a file. I tried the
$pattern = "/[aA] [hH]ref=\"[.]*\"*>/"; $line = eregi_replace($pattern, "", $line);
but nothing happend. Any ideas?
How about something like this:
<?PHP $str = 'this is some text with a <a href="link.htm">link</a> and more text'; $str = preg_replace("/<a(.*?)<\\/a>/i","",$str); echo $str; ?>
Not very well. While it worked well with your test, I need to just strip the tag, not the inside code!!! Additionaly, it did not worked with the lines of the source file (especialy when the tag was on an image). I suppose that I have to find some other example. Thank you anyway.... Peter
Hmm... I don't think I understand what you need. Could you try re-explaining?
that will do:
$s = '<a name="asd">rip</a> \\'em <a href="" lala="">off</a>!'; echo preg_replace('/(<a(.*?)>|<\\/a>)/is', '', $s);
for unknown reasons this board inserts a space after the closing a in the regexp. ignore it :-)