|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm running a script that at one point will collect <img> tags 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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Hi,
If the tag spans multiple lines you'll need the dot all option (insert an s after the last / delimiter). Regards, John Peters On Feb 27, 8:35 pm, dysfunct <Dysfunct...@gmail.com> wrote: > I'm running a script that at one point will collect <img> tags 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 |
|
![]() |
| Outils de la discussion | |
|
|