You are here: Re: How can I find img tags containing line feeds with preg_match_all? « All PHP « IT news, forums, messages
Re: How can I find img tags containing line feeds with preg_match_all?

Posted by Amnesiac5 on 07/08/05 00:21

"Derick van Niekerk" <derick@just.ask> wrote in message
news:daiqeq$mhh$1@ctb-nnrp2.saix.net...
> Don't know too much about regexes, but if I understand you correctly,
> you only need to match the tag:
> $patt = "!(<\s*img\s+[^>]+>)!";
>
> Your original pattern doesn't match whitespaces ;)
>
> Tested it in regex coach (http://www.weitz.de/regex-coach/) and it works
> fine.
:
:snip
:
> Anyway - I hope you managed to get it to work.
>
> -d-

Just about finished. Unfortunately, your pattern doesn't find
<IMG title ="displays" src ="image.gif" alt="image (9K)" />
(note the use of upper-case)
nor
<img title ="displays >"
src ="image.gif"
alt="image (9K)" />
(note the extra ">" in the title attribute string).
Two more cases I came across after your post.

This slightly modified pattern from haacked.com does
$patt =
"!(<[Ii][Mm][Gg]((\s+\w+(\s*=\s*(?:\".*?\"|\'.*?'|[^\'\">\s]+))?)+\s*|\s*)/?
>)!";

Incidentally, the first \s isn't required as < img isn't valid (at least, it
doesn't render in any of the browsers I use). Couldn't have figured it out
without the pointers though.

Many thanks for all the advice and help, much appreciated. Apologies for the
delay in replying, I can't post at work.

A5

 

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

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