in reply to Regex For HTML Image Tags?
use HTML::Parser; HTML::Parser->new( default_h => [sub { print shift; }, "text"], start_h => [sub { my ($text, $tagname,$attr) = @_; return print $text unless $tagname eq "img"; if ($attr->{alt}) { print "[image: \"$attr->{alt}\"]"; } else { print "[image]"; } }, "text,tagname,attr"], )->parse(join "", <DATA>); __END__ <IMG SRC="foo"><BR> bar bar bar<BR> <IMG SRC="foo" alt="bar">
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex For HTML Image Tags?
by hostile17 (Novice) on Mar 28, 2001 at 04:35 UTC |