fork(2) download
  1. import java.util.regex.*;
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String s = "12,34,98,11";
  11. Pattern p = Pattern.compile("(?:\\G(?!^),|^(?=\\d{2}(?:,\\d{2})*$))(\\d{2})");
  12. Matcher m = p.matcher(s);
  13. List<String> results = new ArrayList<>();
  14. while(m.find()) {
  15. results.add(m.group(1));
  16. }
  17. System.out.println(results);
  18. }
  19. }
Success #stdin #stdout 0.07s 33860KB
stdin
Standard input is empty
stdout
[12, 34, 98, 11]