Created
June 7, 2012 19:12
-
-
Save mshock/2890951 to your computer and use it in GitHub Desktop.
toggle commented script tags in .aspx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
my $delim = $/; | |
undef $/; | |
my $file = <DATA>; | |
$/ = $delim; | |
$file =~ s/(<%--)?\s*<script(.*?)>/($1 ? '' : "\n<%-- ") . "<script$2>"/ige; | |
$file =~ s=</script>\s*(-->)?='</script>' . ($1 ? '' : " -->\n")=ige; | |
print $file; | |
__DATA__ | |
<script type="java/js"> | |
foobie bletch | |
</script> | |
<%-- <script> | |
zelgo mer | |
</script> --> |
Note - it looks like github's perl markup isn't smart enough to recognize alternative regex delimiters. Or __DATA__
tokens: https://gist.github.com/2891256
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Slurp an aspx file and comment uncommented script tags and uncomment commented script tags. Probably could fit it all in one regex...