Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need a regular expression that works in Notepad++ to remove multiline javascript references in several hundred HTML files. The code I want to remove looks like this:

<script type="text/javascript" language="JavaScript">
<!--
function ehlp_showtip(current,e,text)
{
  if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == 'Netscape'))
  {
    document.tooltip.document.write("<layer bgColor='yellow' style='border:1px solid black;font-size:12px;'>"+ text + "<\/layer>");
    document.tooltip.document.close();
    document.tooltip.left=e.pageX+5;
    document.tooltip.top=e.pageY+5;
    document.tooltip.visibility="show";
  }
}
function ehlp_hidetip()
{
  document.tooltip.visibility="hidden";
}
//-->
</script>
<script type="text/javascript" language="JavaScript">
<!--
function reDo() {
  if (innerWidth != origWidth || innerHeight != origHeight)
     location.reload();
}
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
        origWidth = innerWidth;
        origHeight = innerHeight;
        onresize = reDo;
}
onerror = null; 
//-->
</script>

Obviously I want to replace everything from <script type="text/javascript" language="JavaScript"> to the closing script tag.

Let me know if you need more info.

share|improve this question
    
On a lighter note: stackoverflow.com/questions/1732348/… –  Nifle Dec 3 '12 at 21:35
add comment

1 Answer

up vote 1 down vote accepted

According to this post recent versions of notepad++ can deal with multi-line regexes. So, if you have the option:

[ ] . matches newline

select it and try this regex:

<script.*?/script>

Backup your files before doing this, I don't use notepad++ (I prefer the glorious thing that are regexes in Perl or emacs :)) so I can't test it.

share|improve this answer
    
for some reason that is only matching single lines even tho I have the '. matches newline' option checked :( –  Richie086 Dec 2 '12 at 21:45
    
Do you have 'Regular expression' checked. I've just tried this and it works in the latest version of Notepad++. –  snowdude Dec 3 '12 at 15:23
    
@Richie086, just making sure you get snowdude's comment. –  terdon Dec 3 '12 at 15:37
    
I had to modify this slightly, but overall I was able to make it work for my purposes. Thanks for answering. –  Richie086 Dec 3 '12 at 21:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.