Was: ereg parse error problem Now: RegEx Plea for Help
| From: | Lara J. Fabans | Date: | Fri, 13 Jul 2001 03:14:21 +0000 |
| Subject: | Was: ereg parse error problem Now: RegEx Plea for Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-57679@lists.php.net to get a copy of this message | ||
Thank you, Phil, for fixing that. Obviously this snippet is trying to be a smaller test case for a much
larger problem. It looks like I'm pulling *all* of the <img> and <a href> from the $string and I don't
want that at all. I just want one of them.
So, my return is:
image source:http://www.123posters.com/images/m-mase01.jpg" alt="Mase Necklace"></a> <img src="http://www.qksrv.net/image-297915-361662" height="1" width="1" border="0
href: http://www.qksrv.net/click-297915-361662" target="_top" > <img src="http://www.123posters.com/images/m-mase01.jpg" alt="Mase Necklace"></a> <img src="http://www.qksrv.net/image-297915-361662" height="1" width="1" border="0
I mistakenly though it would stop at the second ", but it's going all the way to the end. Is there any way to tell it to
find one instance instead of the globalizing like it's doing?
I'm going to play around with a few more things, but after staring at the code for 4 hours, my brain is fried.
Thanks,
Lara
At 06:59 PM 7/12/2001 -0700, Lara J. Fabans wrote:
--------- <?php $string = "<a href="http://www.qksrv.net/click-297915-361662" target="_top" > <img src="http://www.123posters.com/images/m-mase01.jpg" alt="Mase Necklace"></a> <img src="http://www.qksrv.net/image-297915-361662" height="1" width="1" border="0">"; if (ereg ("img src="(.*)"", $string, $regs)) {--------------------- Lara J. Fabans Lodestone Software, Inc lara@lodestone-sw.comecho "image source:$regs[1]<br>";} else { echo "nope1"; } if (eregi("a href="(.*)"", $string, $regs)) { echo "href: $regs[1]<br>"; } else { echo "nope2"; } ?>