Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regex: Strip <script> tags?

by rodion (Chaplain)
on Mar 21, 2007 at 16:06 UTC ( #605873=note: print w/replies, xml ) Need Help??


in reply to Regex: Strip <script> tags?

skx has beter advice, but as for the question as you posed it:
s/<script[^>]*>.*?<\/script>//igs;
should work. It accepts any characters that are not ">", up to the ">" that terminates the tag. It may not be the best solution to this particular problem, but it's a very handy regex idiom to have ready access to.

Replies are listed 'Best First'.
Re^2: Regex: Strip <script> tags?
by ikegami (Pope) on Sep 02, 2007 at 20:01 UTC

    It lets the following through:

    <<script></script>script>...</script>

    It's also a poor regexp in a more general sense since it it doesn't check if the > actually closes the tag of it's inside the quotes of an attribute value.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2021-09-19 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?