Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: How to remove HTML tags from text

by nejcPirc (Acolyte)
on Feb 04, 2005 at 06:54 UTC ( [id://428022]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: How to remove HTML tags from text
in thread How to remove HTML tags from text

Something like this?
$data=~s/<.*?>//g; $data=~s/&lt.*?&gt//g;

Replies are listed 'Best First'.
Re^3: How to remove HTML tags from text
by pelagic (Priest) on Feb 04, 2005 at 07:17 UTC
    Text::Balanced does it properly even if there is some funny stuff between the brackets. Look into the documentation for more info. But of course you can also use some regex to remove the strings in a simple way.

    pelagic
Re^3: How to remove HTML tags from text
by cLive ;-) (Prior) on Feb 04, 2005 at 19:00 UTC
    nope.
    $data = <<_END_; <script language="JavaScript"> alert("Boo!") </script > _END_
    A /s modifier would help a little, but doesn't solve everything. Eg, what about this tag?
    $data = qq{ <img src="hello.jpg" alt="x>y" width="60" height="60" /> } +;

    Lesson: never treat HTML parsing as a "back of an envelope" exercise :)

    cLive ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://428022]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.