Skip to content

Instantly share code, notes, and snippets.

@sophistifunk
Forked from anonymous/regex
Created September 25, 2012 12:55
Show Gist options
  • Save sophistifunk/3781622 to your computer and use it in GitHub Desktop.
Save sophistifunk/3781622 to your computer and use it in GitHub Desktop.
regex
String inputLine = "append \"bow wow wow yippee-o yippee-ay\" dir1/dir2/file.txt";
Pattern regex = Pattern.compile("^(\\w+)\\s+\"(.*?)\"\\s+([\\w.\\/]+)$");
Matcher m = regex.matcher(inputLine);
String cmd = m.group(1); // append
String data = m.group(2); // snooplish
String path = m.group(3); // What's left
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment