This is a case of "don't use regexes to parse HTML" :)
#!perl -w use strict; use HTML::Parser; my $html = <<'END_HTML'; <html> <body> <form action="/foo.pl" method="post"> Username: <input type="text" name="user" onClick="alert('You clicked me!')" /><br /> Password: <input type="password" name="passwd" onChange="alert('You changed me!')" /> </form> </body> </html> END_HTML my $parser = HTML::Parser->new( start_h => [ \&_parser_starttag, 'tagname, attr' ] ); $parser->parse( $html ); sub _parser_starttag { my ($tag, $attr) = @_; if ( exists $attr->{'onchange'} ) { warn( "<$tag> - onChange: ", $attr->{'onchange'}, "\n" ); } elsif ( exists $attr->{'onclick'} ) { warn( "<$tag> - onClick: ", $attr->{'onclick'}, "\n" ); } }
In reply to Re: Regular expression problem
by saskaqueer
in thread Regular expression problem
by jockel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |