preg_match_all issue, need some help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dysfunct

    preg_match_all issue, need some help

    I'm running a script that at one point will collect <imgtags from
    some html. I've been using the following:

    preg_match_all( "/<img .*?>/",$html,$images );

    and I thought it was working well. However, I've notice that some
    things i throw at it don't work properly. It seems to be that and
    image tag closing itself with "/>" doesn't work, ie <img src="..... " /
    >. I'm guessing the "/" character is delimiting the regex somehow.
    Admittedly I know very little about regular expressions. Anyone know
    whats going on and the best way to get all the image tags? I ideally
    would like the whole thing, from the <img to the final closing bracket
    >.
  • Rik Wasmus

    #2
    Re: preg_match_all issue, need some help

    On Thu, 28 Feb 2008 02:30:58 +0100, dysfunct <DysfunctY2K@gm ail.comwrote:
    I'm running a script that at one point will collect <imgtags from
    some html. I've been using the following:
    >
    preg_match_all( "/<img .*?>/",$html,$images );
    >
    and I thought it was working well. However, I've notice that some
    things i throw at it don't work properly. It seems to be that and
    image tag closing itself with "/>" doesn't work, ie <img src="..... " /
    >. I'm guessing the "/" character is delimiting the regex somehow.
    Admittedly I know very little about regular expressions. Anyone know
    whats going on and the best way to get all the image tags? I ideally
    would like the whole thing, from the <img to the final closing bracket
    preg_match_all( "/<img[^>]*>/",$html,$images );

    However, proper use of DOM & getElementsByTa gName() could be more easily
    maintained.

    --
    Rik Wasmus

    Comment

    Working...