develooper Front page | perl.fwp | Postings from May 2003

Stripping HTML

From:
Matt Groves
Date:
May 17, 2003 07:15
Subject:
Stripping HTML
Message ID:
029501c31c7f$30c61ca0$0200a8c0@bishop
Hello,

I'm not sure if this classifies as "fun with perl", but here goes anyway.

I have a textarea in a form on an HTML page which is passed to a cgi script.
I want to make sure that no HTML is put into this textarea.  So far I have
come up with the following to strip it out, but I want to know if anyone has
any clever ideas, or extensions to this, or can make it even smaller !

        $inbound =~ s/\<.*\>//g ;
        $inbound =~ s/\&lt.*\&gt//g ;
        $inbound =~ s/\&lt\;.*\&gt\;//g ;
        $inbound =~ s/\&amp\;lt.*\&amp\;gt//g ;

Thanks in advance,

Matt.





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About