Support » Fixing WordPress » Regular expressions. How to select this from post….

  • Hi All,

    I want to be able to remove an image from a post to use in isolation. There are many scripts out there which make use of a reg exp to do this and they work great. BUT I have the following image code:

    <a class="screenshot" rel="wp-content/uploads/2010/05/pop6_pv1.gif" href="?p=39"><img class="alignnone size-full wp-image-40" title="pop6" src="http://localhost/wp-content/uploads/2010/04/pop6.gif" alt="" width="196" height="137" /></a>

    This has a hover over effent going on. But when I run this through this ~<img [^\>]*\ />~ I loose the class and rel aspects of the link. So I neex to select the whole string as above but being such a novice with reg ex I’m pretty much lost.

    Can anyone help?

    Sarah

Viewing 1 replies (of 1 total)
  • I don’t have the time to give you the exact expression, but what you’re looking for is more than likely related to greedy vs non-greedy quantifier ?.

    If this is something you will continually be using, I highly recommend finding a module to parse your HTML. Using regular expressions to parse HTML is incredibly difficult and will not be correct as often as you might think. Even if you’re well versed in RE people recommend using a module, otherwise you’re walking down the path of insanity.

Viewing 1 replies (of 1 total)
  • The topic ‘Regular expressions. How to select this from post….’ is closed to new replies.