fork(1) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String str = "\"Name\":\"jon\" \"location\":\"3333 abc street\" \"country\":\"usa\"";
  9. Pattern p = Pattern.compile("(.+?)(\\s+(?=(?:(?:[^\"]*\"){2})*[^\"]*$)|$)");
  10. Matcher m = p.matcher(str);
  11. for (int i=0; m.find(); i++)
  12. System.out.printf("Scol[%d]: [%s]%n", i, m.group(1).replace("\"", ""));
  13. }
  14. }
Success #stdin #stdout 0.08s 380224KB
stdin
Standard input is empty
stdout
Scol[0]: [Name:jon]
Scol[1]: [location:3333 abc street]
Scol[2]: [country:usa]