(String[] args)
| 15 | "Beware the Jubjub bird, and shun\n" + |
| 16 | "The frumious Bandersnatch."; |
| 17 | public static void main(String[] args) { |
| 18 | Matcher m = Pattern.compile( |
| 19 | "(?m)(\\S+)\\s+((\\S+)\\s+(\\S+))$") |
| 20 | .matcher(POEM); |
| 21 | while(m.find()) { |
| 22 | for(int j = 0; j <= m.groupCount(); j++) |
| 23 | System.out.print("[" + m.group(j) + "]"); |
| 24 | System.out.println(); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | /* Output: |
| 29 | [the slithy toves][the][slithy toves][slithy][toves] |