|
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]
|