fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.regex.*;
  6.  
  7. class Ideone {
  8. public static void main (String[] args) throws java.lang.Exception {
  9. String input = "name:\"SFATG\";affil:100;aup:1;bu:FALSE name:\"SF TAC 1\";affil:29.3478;aup:19;bu:FALSE name:\"SF TAC 2\";affil:22.2222;aup:14;bu:FALSE name:\"SF TAC 3\";affil:44.4444;aup:0;bu:FALSE name:\"SF DISP 4\";affil:82.4742;aup:0;bu:FALSE ";
  10.  
  11. Pattern p = Pattern.compile("\\w+:(?:\"([^\"]+)\"|(\\d+)(?=;|\\Z)|(\\d+\\.\\d+)|([A-Z]+\\s))");
  12.  
  13. Matcher m = p.matcher(input);
  14.  
  15. while (m.find()) {
  16. System.out.println("Found " + m.group() + ".");
  17. }
  18. }
  19. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
Found name:"SFATG".
Found affil:100.
Found aup:1.
Found bu:FALSE .
Found name:"SF TAC 1".
Found affil:29.3478.
Found aup:19.
Found bu:FALSE .
Found name:"SF TAC 2".
Found affil:22.2222.
Found aup:14.
Found bu:FALSE .
Found name:"SF TAC 3".
Found affil:44.4444.
Found aup:0.
Found bu:FALSE .
Found name:"SF DISP 4".
Found affil:82.4742.
Found aup:0.
Found bu:FALSE .