I am trying to remove some garbage js code on 4k+ webpages. The webpages have other js on the page as well so I need to only get rid of the JS with a particular function called clickIE.
I have this one liner working until I introduce the regex...
perl -p -i -e 's|<script(.*)>.*clickie.*?<\/script>|<\!--REMOVED-JS-CODE-->|gixsm' ./*.html
My regex works correctly when tested at http://www.gskinner.com/RegExr/ but fails on the command line...(fails meaning... the regex doesnt match anything)
perl -p -i -e 's|<script(.*?)>.*?clickie.*?<\/script>|<\!--REMOVED-JS-CODE-->|gixsm' ./*.html<script>console.log("clickie")</script>. Admittedly, it's unlikely that you'll find 'clickie' in quotes anywhere in the sources you're looking at, but in the general case that may be less likely. Fixing this safely involves using a javascript parser to only find cases where the target string is being used as a function name, which is a somewhat harder problem.