Was: ereg parse error problem Now: RegEx Plea for Help

From: 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 &quot;, 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 = "&lt;a href=&quot;http://www.qksrv.net/click-297915-361662&quot; target=&quot;_top&quot; &gt; &lt;img src=&quot;http://www.123posters.com/images/m-mase01.jpg&quot; alt=&quot;Mase Necklace&quot;&gt;&lt;/a&gt; &lt;img src=&quot;http://www.qksrv.net/image-297915-361662&quot; height=&quot;1&quot; width=&quot;1&quot; border=&quot;0&quot;&gt;"; if (ereg ("img src=&quot;(.*)&quot;", $string, $regs)) {
       echo "image source:$regs[1]<br>";
} else { echo "nope1"; } if (eregi("a href=&quot;(.*)&quot;", $string, $regs)) { echo "href: $regs[1]<br>"; } else { echo "nope2"; } ?>
--------------------- Lara J. Fabans Lodestone Software, Inc lara@lodestone-sw.com

« previous php.general (#57679) next »