fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String regex = "\\bString\\h+\\[([0-9]+(?:,\\h+[0-9]+)*)\\]";
  12. String string = "String [81, 82, 83, 84, 85, 86, 87, 88, 89, 90]";
  13.  
  14. Pattern pattern = Pattern.compile(regex);
  15. Matcher matcher = pattern.matcher(string);
  16.  
  17. if (matcher.find()) {
  18. String[] array = matcher.group(1).split(",\\h+");
  19. System.out.println(Arrays.toString(array));
  20. }
  21. }
  22. }
Success #stdin #stdout 0.06s 33944KB
stdin
Standard input is empty
stdout
[81, 82, 83, 84, 85, 86, 87, 88, 89, 90]