I am usng preg_match
with the pattern $pattern = '/src="http:\/\/(.*?).jpg"/s';
to grab urls of jpeg images off a webpage. However, this is not accurate enough as it also grabs http://www.domain.com/image.png"> Yadayada <img src="anotherpic.jpg
.
Other times, it grabs stuff like
http://maps.google.com/maps/api/staticmap?center=42.34,-71.18&path=weight:4|42.338,-71.177|42.338,-71.183|42.342,-71.183|42.342,-71.177|42.338,-71.177&zoom=15&size=335x225&sensor=false" width="280" height="188" alt=""></td></tr> <tr><td height="10"></td></tr></table></td></tr></table></td></tr><tr><td height="10 valign="> </td></tr><tr><td valign="top" background="http://www.coolapartments.info/img/java-footer_bg.jpg
How can I improve the pattern to prevent unwanted matching like the 2 examples above?