By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

preg_match_all issue, need some help

P: n/a
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
>.
Feb 28 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Thu, 28 Feb 2008 02:30:58 +0100, dysfunct <Dy*********@gmail.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 & getElementsByTagName() could be more easily
maintained.

--
Rik Wasmus
Feb 28 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.