The example below shows how to use regex.MatchResult and Scanner to find the required matches.

Java Code:
                     String input = "1 fish 2 fish red fish blue fish";
		     Scanner s = new Scanner(input);
		     s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)");
		     MatchResult result = s.match();
		     for (int i=1; i<=result.groupCount(); i++)
		         System.out.println(result.group(i));
		     s.close();