perl regex find & replace
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)
For the regex to work, the entire file needs to be slurped in at once.
$ perl -0777 -pi -e 's/your/regex/gix' ./*.html
As noted by @Mark the matches should be non-greedy. This seems to work...
perl -i -p -e 's|<script.*?>.*?clickie.*?</script>|<!-- removed -->|gism'