You are here: Re: Regular Expression to extract all .JPG and .PNG URL's « PHP Programming Language « IT news, forums, messages
Re: Regular Expression to extract all .JPG and .PNG URL's

Posted by Paul Lautman on 10/13/07 11:43

Steve wrote:
>> preg_match_all("/.*(jpg|png)$/", $htmlfile, $Matches);
>
> nah...that would mean:
>
> ghijpgklmno
>
> or
>
> mnopngqrst
>
> or any text having those letters within it would be captured. however,
> neither his nor yours work unless the string ends at the end of the
> line (eof or \r or \n). both don't escape the dot...so that means
> 'any character followed by jpg or png'. more marginal success would
> be had just doing, "/\.jpg|\.png/", but even that doesn't cut
> it...since either jpg or png can be followed by anything and still be
> captured. not to mention we've left out jpeg's.
>
> make sense?

Well it seems to be a bit of a contradiction. My one was intended to only
find png or jpg at the end of the line as that was what the OP had intimated
was required.

Now you can hardly say that it would match ghijpgklmno or mnopngqrst at the
same time as saying that it'll only match with png or jpg at the end of the
line!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация