fork(17) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.Pattern;
  4. import java.util.regex.Matcher;
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String test ="(1,2),(3,4),(5,6)";
  11. for (String s : test.split("\\),\\(|\\)|\\(")) {
  12. System.out.println("'"+s+"'");
  13. }
  14. Pattern pattern = Pattern.compile("\\(([^\\)]*)\\)");
  15. Matcher matcher = pattern.matcher(test);
  16. while (matcher.find()) {
  17. System.out.println("{" + matcher.group(1)+ "}");
  18. }
  19. }
  20. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
''
'1,2'
'3,4'
'5,6'
{1,2}
{3,4}
{5,6}