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

Re: Regex: Strip <script> tags?

by sanPerl (Friar)
on Mar 22, 2007 at 06:26 UTC ( [id://605964]=note: print w/replies, xml ) Need Help??


in reply to Regex: Strip <script> tags?

It is better to use some ready-to-eat kind of CPAN module. However if you want a simple soltion then here it is.
It will work for following kinds of tags
1) <script> ( should be deleted )
2) <script a="aaa"> (should be deleted )
3) <script1> (This should be retained by regex)
4) ANY OTHER TAG other than mentioned above (This should be retained by regex)
## This is required so that we can escape processing of tags like <scr +ipt1>, <scriptabc>,<scriptxyz>....etc from deletion s/<script>/<script >/igs; s/<script\ .*?>.*?<\/script>//igs;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2026-02-08 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    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.