fork download
  1.  
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4. import java.util.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8.  
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. String regex = "\\[(?:\\d+,\\h+)*(\\d+)]";
  14. String string = "[72, 216, 930],[250],[72],[228, 1539],[12]";
  15.  
  16. Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
  17. Matcher matcher = pattern.matcher(string);
  18.  
  19. while (matcher.find()) {
  20. System.out.println(matcher.group(1));
  21. }
  22. }
  23. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
930
250
72
1539
12