!636 !standard functions !680 // "quicknew" main { psvm { String text; if (args.length != 0) text = loadSnippet(args[0]); else { text = loadTextFile("input/input.txt", null); if (text == null) text = loadSnippet("#1000341"); // example input } Matcher m = Pattern.compile("(#\\d+)").matcher(text); new StringBuffer buf; // cool "quicknew" syntax! while (m.find()) m.appendReplacement(buf, m.quoteReplacement(formatSnippetRef(m.group()))); m.appendTail(buf); text = buf.toString(); text = text.replaceAll("\r?\n\r?\n", "\n

\n"); saveTextFile("output/output.txt", text); System.out.println(text); } static String formatSnippetRef(String in) { in = in.substring(1); in = "#%!%".replace("%!%", in); return in; } }