// A JavaX extension for multi-line strings, modelled after Lua [[ ]] quotes. !592 1000265 // auto-importer, standard function adder public class main { public static void main(String[] args) throws Exception { String s = loadMainJava(); StringBuffer out = new StringBuffer(); // [\s\S] is a clever trick to match all characters including newlines. Pattern regex = Pattern.compile("\\[\\[([\\s\\S]*?)\\]\\]"); Matcher matcher = regex.matcher(s); //print "Matching source code" while (matcher.find()) { //print "double brackets found" String string = matcher.group(1); string = string.replaceAll("^[\t ]*\r?\n", ""); // first newline is ignored in Lua too //System.out.println("String: " + string); String replacement = makeJavaStringLiteral(string); //stem.out.println("Replacement: " + replacement); matcher.appendReplacement(out, matcher.quoteReplacement(replacement)); // quoting is important... } matcher.appendTail(out); s = out.toString(); //System.out.println("Translated source:\n" + s); saveMainJava(s); } }