Apply striptags() selectively on <a> tags
Posted: Thu Dec 16, 2010 3:32 am
Hi there,
I want to apply the striptags() function selectively on <a> tags containing some specific pattern in the URL.
e.g. I have text that contains two different sorts of <a> tags:
sort 1:
<a href=/dirname1/somepage>something</a>
sort 2:
<a href=/dirname2/somepage>something</a>
note that "somepage" and "something" can vary from tag to tag. the different URL sorts can be distinguished by dirname1 or dirname2.
now, I want to scan the text and remove all <a> tags pointing to URLs that begin with /dirname1, while I want to keep all other tags.
after removal of sort 1 tags, only the anchors "something" should be left over.
how could this be done?
thanks for your help.
-saudepp
I want to apply the striptags() function selectively on <a> tags containing some specific pattern in the URL.
e.g. I have text that contains two different sorts of <a> tags:
sort 1:
<a href=/dirname1/somepage>something</a>
sort 2:
<a href=/dirname2/somepage>something</a>
note that "somepage" and "something" can vary from tag to tag. the different URL sorts can be distinguished by dirname1 or dirname2.
now, I want to scan the text and remove all <a> tags pointing to URLs that begin with /dirname1, while I want to keep all other tags.
after removal of sort 1 tags, only the anchors "something" should be left over.
how could this be done?
thanks for your help.
-saudepp