Here's an example using HTML::TokeParser
#!/usr/bin/perl -w use strict; use HTML::TokeParser; # Regex representing the list of acceptable tags my $ok_stuff = qr/^(p|br|h.|font|pre)$/; # Some test html. my $html = "<p><br><h3><a href='evil.js'>Testing</a></h3></p>\n"; # Instantiate the TokeParser my $parser = new HTML::TokeParser (\$html); # Loop until all tokens are read while (my $token = $parser->get_token()) { # Immediately print any "text" token if ($token->[0] eq "T") { print $token->[1]; } # Check all other tokens against the regex before printing elsif ($token->[1] =~ $ok_stuff) { print $token->[$#{$token}]; } }
The above code prints out "<p><br><h3>Testing</h3></p>"
-Matt
In reply to RE: BBS HTML fitler
by DrManhattan
in thread BBS HTML fitler
by tkroll
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |