Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Strip HTML tags

by epoptai (Curate)
on Dec 16, 2000 at 06:41 UTC ( [id://47016]=note: print w/replies, xml ) Need Help??


in reply to Strip HTML tags

Some regexes that 'work' for this, the first is from the great free code syntax highlighter code2html.pl:
($text = $html) =~ s/<(\/|!)?[-.a-zA-Z0-9]*.*?>//g;
These are obvious (but too simple) solutions:
$text =~ s/<[^>]*>//gs; # only for most simple html! $text =~ s/<([^>]|\n)*>//g; # multi-line comments?
For in-depth discussion consult Perl Cookbook Recipe 20.6 which recommends using the HTML::Parser and HTML::FormatText modules.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://47016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-16 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found