fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5. import java.util.*;
  6. import java.lang.*;
  7. import java.io.*;
  8. import java.util.Arrays;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. List<String> result = new ArrayList<String>();
  16. String input = "[dgdds,dfse][fsefsf,sefs][fsfs,fsef]";
  17. Pattern pattern = Pattern.compile("\\[.*?\\]");
  18. Matcher matcher = pattern.matcher(input);
  19. while (matcher.find())
  20. {
  21. result.add(matcher.group());
  22. }
  23. System.out.println(result);
  24. }
  25. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
[[dgdds,dfse], [fsefsf,sefs], [fsfs,fsef]]