Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Strip HTML tags again

by ides (Deacon)
on Jun 30, 2002 at 15:47 UTC ( [id://178376]=note: print w/replies, xml ) Need Help??


in reply to Strip HTML tags again

This will probably do the trick, however this does not handle HTML tags that span multiple lines. To do that you'll most likely have to join all the lines together into one scalar. This will also not catch multiple HTML tags on the same line, you'll need to modify it to suit your needs.

What this is doing is finding text contained in <>'s that has a corresponding ending tag.

Here is the code ($l is the scalar holding the line of text):

if( $l =~ /<.*?>(.*?)<\/.*?>/ ) { $l = $1; }

-----------------------------------
Frank Wiles <frank@wiles.org>
http://frank.wiles.org

Replies are listed 'Best First'.
Re: Re: Strip HTML tags again
by dda (Friar) on Jun 30, 2002 at 16:03 UTC
    Thanks, but I need a solution which 'knows' about possible HTML tags. What I need is to filter HTML from a chat message, and if someone type '<Hehe>' - it will be wiped off.

    --dda

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found