BillyBoB Posted April 7, 2008 Share Posted April 7, 2008 I'm need to remove the <a> tag from any text but leave all other tags. The <a> tag could include any possible attributes including those like id, class, or href. If you can help me that would be great or just point me in the right direction. I have been working on this for hours still nothing comes up. Link to comment https://forums.phpfreaks.com/topic/99917-removing-the-tag-with-regex/ Share on other sites More sharing options...
Orio Posted April 7, 2008 Share Posted April 7, 2008 <?php $str = 'Some <b>Text </b><span><a href="1.html"> 11</a><A href="1.htm"> ewfwm</a></span> <u>Hello</u>'; $pattern = "/<a ?.*<\/a>/si"; $replacement = ""; echo preg_replace($pattern, $replacement, $str); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/99917-removing-the-tag-with-regex/#findComment-511098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.