package org.ibex.util;
+import gnu.regexp.*;
import java.util.*;
import java.io.*;
*/
public class Preprocessor {
+ public static String replaceAll(String source, String regexp, String replaceWith) {
+ try {
+ RE re = new RE(regexp, 0, RESyntax.RE_SYNTAX_PERL5);
+ return (String)re.substituteAll(source, replaceWith);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
if (key != null) {
Hashtable hash = byLength[key.length()];
- hash.put(key, (String)hash.get(key) + processLine(trimmed, false).replaceAll("//[^\"]*$", "").trim() + "\n");
+ hash.put(key, (String)hash.get(key) + replaceAll(processLine(trimmed, false), "//[^\"]*$", "").trim() + "\n");
} else {
out.print(processLine(trimmed, false));
}
String bound2 = null;
if (unbound2 == null) {
bound1 = args;
- return expression.replaceAll(unbound1, bound1);
+ return replaceAll(expression, unbound1, bound1);
} else {
bound1 = args.substring(0, args.indexOf(','));
bound2 = args.substring(args.indexOf(',') + 1);
- return (expression.replaceAll(unbound1, bound1).replaceAll(unbound2, bound2));
+ return replaceAll(replaceAll(expression, unbound1, bound1), unbound2, bound2);
}
}
}