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 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'

Need Your Help

How are Shadow DOM events from under <content> targeted?

polymer web-component shadow-dom

I'm trying to understand what events that originate in light DOM look like when received in shadow DOM via a &lt;content&gt; element. I'm reading the Shadow DOM W3C Draft, and I don't entirely unde...

Remove the tick bar on flot charts

javascript jquery charts flot

Is it possible to remove the tick bars on the x and y axis on a flot chart?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.