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

Stripping HTML

Matt Groves
May 17, 2003 07:15
Stripping HTML
Message ID:

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. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About