calabiyau Posted April 4, 2007 Share Posted April 4, 2007 <img style="width: 91px; height: 76px" src="images/star.gif" border="1" alt="star" title="star" hspace="1" vspace="1" width="91" height="76" align="left" /> Tricky question for the above line of html. I have a content editor for a blog that outputs this piece of code for inserting an image. However I am trying to have a rich text format export option to export the blog entries and want to replace all the above with a simple tag like <missing image>. So I am looking for something that will take everything between <img and /> and replace it, without affecting any other occurences of things like width, height, etc that occur elsewhere on the page outside the image tage. Anybody have any idea of how this could be done? Link to comment https://forums.phpfreaks.com/topic/45630-solved-replacing-everything-between-two-strings/ Share on other sites More sharing options...
calabiyau Posted April 4, 2007 Author Share Posted April 4, 2007 And I have tried using strip tags to just get rid of the image tags altogether but it seems to stop all the rest of the content on the blog entry from displaying. Link to comment https://forums.phpfreaks.com/topic/45630-solved-replacing-everything-between-two-strings/#findComment-221663 Share on other sites More sharing options...
fert Posted April 4, 2007 Share Posted April 4, 2007 $text=preg_replace("/<img (.*) \/>/","<missing image>",$text); Link to comment https://forums.phpfreaks.com/topic/45630-solved-replacing-everything-between-two-strings/#findComment-221665 Share on other sites More sharing options...
calabiyau Posted April 4, 2007 Author Share Posted April 4, 2007 Thanks, worked perfectly.I've been avoiding regular expressions like the plague, but I guess it's time to learn! Link to comment https://forums.phpfreaks.com/topic/45630-solved-replacing-everything-between-two-strings/#findComment-221678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.