Skip to content

Instantly share code, notes, and snippets.

@deathbeam
Last active August 29, 2015 14:16
Show Gist options
  • Save deathbeam/a9205246592fb8babb13 to your computer and use it in GitHub Desktop.
Save deathbeam/a9205246592fb8babb13 to your computer and use it in GitHub Desktop.
Mirah import -> require
import java.util.regex.*;
class ItoR {
public static void main (String[] args) {
String source = "require \"non/Graphics\"\n" +
"require \"non/graphics\"\n" +
"require \"non/GFX\"\n" +
"require \"non/Audio\"\n";
System.out.println(source + "\n");
Pattern pattern = Pattern.compile("(\\s*)(require)(\\s?)(\")(.+)(\")");
Matcher matcher = pattern.matcher(source);
source = matcher.replaceAll("import $5\n");
System.out.println(source);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment