0

I'm parsing rss feeds however some feeds have what look to be blank images in them (from feedburner). Can somewhere help me out with a preg_replace command to find and remove an image tag structured like:

<img src="http://feeds.feedburner.com/sdfasdfsfd" height="1" width="1"/>

Thanks!

6
  • 5
    Why you can't parse HTML with regex Commented Oct 1, 2010 at 17:10
  • Remove an image tag? You mean, remove everything from <img to /> ? Commented Oct 1, 2010 at 17:11
  • Why do people always suggest using HTML parsers, whenever someone wants to match/replace something within some html code? Using regular expressions to replace regular occurences within some html code is completely fine.. Commented Oct 1, 2010 at 17:13
  • @poke: Because The <center> cannot hold it is too late Commented Oct 1, 2010 at 17:17
  • @ircmaxell: Might want to read the question and my comment again? This is not about parsing HTML; it is about removing some regular text from a string that might contain html tags. Commented Oct 1, 2010 at 17:23

1 Answer 1

4

I guess the "sdfasdfsfd" is something random:

$text = preg_replace( '#<img src="http://feeds.feedburner.com/[a-z]+" height="1" width="1"/>#i', '', $text );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.