SOME OPTIONS:
- HARD REBOOT ( not fun...)
- killall Dock (reqires access to a terminal)
PROMPT $ killall Dock
Shortest blog post I ever wrote... Just trying to get the word out...
-
#Search RegEx # This looks for .jpg, and then does a # NON-Consuming match on a word boundary where there is NOT a ? # For example .jpg" and .jpg' would match, but .jpg?version2 will not \.jpg(?\b)(?[^\?]) #Replacement \.jpg?STATIC_CONTENT_VERSION
use File::Find; use File::Basename; # The inputs: # directory to start in, findRegex, replacement, dryrun indicator @DIRS = $ARGV[0]; $patternFind = $ARGV[1]; $patternReplace = $ARGV[2]; $dryrun = $ARGV[3]; # process a single file (this sub is called from below) sub processFile{ $baseN=""; $dirN=""; $extN=""; $linesProcessed = 0; $currentFile = $File::Find::name; ($baseN,$dirN,$extN) = fileparse($currentFile,'\..*'); if ($extN eq ".java" || $extN eq ".jsp" || $extN eq ".properties" || $extN eq ".js" || $extN eq ".css" ){ # This represents a file that we want to do a search and replace on. # print "found java $currentFile :$extN:$baseN:$dirN:\n"; }else{ # print "\nRETURNING: $currentFile\n\n"; return; } $currentBaseName = $_; # OPEN THE FILE READ ONLY. open FILE, $currentBaseName; $modify= 0; # DETERMINE IF THE FILE CONTAINS A MATCH while($line =){ if($line =~ /$patternFind/){ $modify++ } } close FILE; if($modify==0){ # THERE WAS NO REGEX MATCH, SO EXIT. return; } # NO IT's not the evil number, # it means set to global read/write in unix. # required for TFS integration. chmod 0666, $currentBaseName; open (FILE, "+< $currentBaseName") or die "can't read $currentFile $!"; $out = ''; while( ){ if($_ =~ /$patternFind/){ $linesProcessed++; print "\tReplace: $_\n"; s/$patternFind/$patternReplace/eg; print "\tWith: $_\n"; } $out .=$_; } if($dryrun==1){ seek(FILE,0,0) or die "can't seek to start of $currentFile $!"; print FILE $out or die "cant't print $currentFile $!"; truncate(FILE, tell(FILE)) or die "can't truncate $currentFile: $!"; close (FILE) or die "can't close $currentFile: $!"; } print "File:$baseN$extN :From ->:$dirN\n"; print "Lines Changed: $linesProcessed\n"; print "___________________________________________________\n"; } find (\&processFile, @DIRS);
package com.ecokrypt... public class ToManySystemOuts { System.out.println("Single Line System.out.println"); System.out.println("Rare multiline " + " System.out.println "); }We need to find a REGEX that will match both of these cases. There are several ways to do any REGEX, but a solution that is easy to understand that will work is:
(?s)System.out.println(\(([^;]+?)\));
(?s)System.out.println(\(([^;]+)?\));
System.out.println$1;
NetBeans in File Search Replace |
NetBeans Replace Across All Files USE CRTL-H for a shortcut to this Menu. |
NetBeans Confirmation Dialog |
The Eclipse Search Dialog. (Allows you to select scope) |