use strict; use HTML::TokeParser::Simple; use Getopt::Std; my $Usage = "Usage: $0 -f word file.html > highlighted.html\n"; my %opts; ( getopts( 'f:', \%opts ) and $opts{f} and @ARGV == 1 ) or die $Usage; $opts{f} =~ tr/,/\|/; # This applies a regex substitution to the text part # and leaves the tags unmodified: while ( my $token = $p->get_token ) { if ( $token->is_text ) { $_ = $token->as_is; s{($opts{$f})}{<b><u>$1</u></b>}g; print; } else { print $token->as_is; } }
(update: forgot to include the assignment to $_)
In reply to Re: Perl regex
by graff
in thread Perl regex
by axl163
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |