fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. //The logic of splitting is that it should be done at the first space before the character ':'
  10. String s = "xbox one gaming-consoles:xbox-one-games:gaming-controllers and more here";
  11. String[] chunks = s.split(" ++(?=[^ :]*:)", 2);
  12. System.out.println(Arrays.toString(chunks));
  13. }
  14. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
[xbox one, gaming-consoles:xbox-one-games:gaming-controllers and more here]