fork(11) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class Test
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. List<String> matchList = new ArrayList<String>();
  9. Pattern regex = Pattern.compile("\\(([^()*])\\)");
  10. Matcher regexMatcher = regex.matcher("Hello This is (Java) Not (.NET)");
  11.  
  12. while (regexMatcher.find()) {
  13. matchList.add(regexMatcher.group(1));
  14. }
  15.  
  16. for(String str:matchList) {
  17. System.out.println(str);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.07s 51932KB
stdin
Standard input is empty
stdout
Standard output is empty