[SOLVED] regexs not finding or replacing
I have been at this fourteen hours, maybe someone can spot something. I have thrown away over a hundered lines of code trying to get some traction.
Purpose of this routine is to replace localhost:0000 with domain.com and back in any occurence in a directory for build deploy versions. I have read the documentation several times, it says replace all replaces all, find() is suppose to find and so on. Nothing is happening.
I do not have much time with regexes.
// Looks for: "localhost:8080"
Pattern localHost = Pattern.compile(
"localhost:8080??", Pattern.CASE_INSENSITIVE);// I tried changing ?? to +
// Looks for: "localhost:8080"
Pattern wwwServer = Pattern.compile(
"wwwServer\\.com??", Pattern.CASE_INSENSITIVE);// tried changing ?? to +
String nextLine = LINE_NUMBER_READER.readLine();
if( nextLine != null )
// Matchers and replacers
wwwURL_matcher = wwwServer.matcher(nextLine);
localHost_matcher = localHost.matcher(nextLine);// Looks for: "localhost:8084"
prototypingDebugLog.append("found www site ");//
prototypingDebugLog.append("found localhost ");//
String local = wwwURL_matcher.replaceAll("localhost:8084");
prototypingDebugLog.append(local + NEW_LINE);//
prototypingDebugLog.append("replace localhost:8080 gets ");//
String remote = localHost_matcher.replaceAll("belvcomp.com");
prototypingDebugLog.append("replace (server).com gets ");//
while( nextLine != null);
Goin dizzy, cannot see the screen anymore. May have missed something.
replace localhost:8084 gets
replace belvcomp.com gets
major progress this morning
I will work that in a moment, I am swamped right now.
Originally Posted by skaspersen
I have a first 100% thanks to: RegEx: online regular expression testing
Norm, how much code do you want? Try this to start with: RegExLib.com Regular Expression Cheat Sheet (.NET Framework)
ftr: I was getting dizzy, it was all I could do to to remove all the fully specified package on every variable and 200 character lines with random strings for variable naming + proprietary removal. What I am trying to do is for an exact URL in the forms I am trying to get running in Servlets: Find and replace ( local | remote ) URL prior to doing a build in NetBeans so as to do testing on local then re-build for deploy on www using an exact swapping of host as defined in:
Each invocation of the tool provides two source files with dot extensions appended after .java
URI(String scheme, String host, String path, String fragment)
leaving the original source file unmodified by doing a LineNumberReader.readline() then doing a BufferedWriter.append to each of the files from the String returned by the Regex's work.
StringBuffer appendDeployExtension= new java.lang.StringBuffer(TestFind_2.this.currentFile.toString());
java.io.BufferedWriter b9544a26263b = new java.io.BufferedWriter(new java.io.FileWriter(appendDeployExtension.toString()));
StringBuffer appendPrototypeExtension= new java.lang.StringBuffer(TestFind_2.this.currentFile.toString());
java.io.BufferedWriter e16f3638c49 = new java.io.BufferedWriter(new java.io.FileWriter(appendPrototypeExtension.toString()));
I would then manually replace the souces in the NetBeans build directory from the shell and launch NetBeans, removing the appropriate file extension. It is telling that the code that NetBeans produces is exactly how I code, the elimination of such things as code folding and sluggish editor forces me to work from a cold-boot having never invoked NetBeans. After NB finishes, I go down to a cold start and do deploy manually to WEB-INF/classes/(app-dir)