fork download
  1. import java.util.*; // import only needed for printing result
  2. class Ideone {
  3. public static void main (String[] args) {
  4. String str = "2\n1\n1 2\n9 3 5\n1 3\n0 9 2 4\n0";
  5. String[] split = str.replaceAll("(?m)^\\d+\\s*", "").split("\\s");
  6. System.out.println(str + "\nsplits to " + Arrays.toString(split));
  7. }
  8. }
Success #stdin #stdout 0.21s 50684KB
stdin
Standard input is empty
stdout
2
1
1 2
9 3 5
1 3
0 9 2 4
0
splits to [2, 3, 5, 3, 9, 2, 4]