fork download
  1. import java.util.regex.*;
  2.  
  3. class T {
  4. public static void main(String[] args) {
  5. String s = "Match foo and bar and baz";
  6. Pattern p = Pattern.compile("Match (.*) and (.*) and (.*)");
  7. Matcher m = p.matcher(s);
  8. while (m.find()) {
  9. System.out.println(m.group(1));
  10. }
  11. }
  12. }
  13.  
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
foo