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 = "(?:abc\\s*\\(\\s*|\\G(?!^),)('[^',]*'|\\w+\\([^()]*\\))";
  12. String string = "and abc ( xyz(d.e),'f','g','h','i',abc('p/q'),'r') = u";
  13. Pattern pattern = Pattern.compile(regex);
  14. Matcher matcher = pattern.matcher(string);
  15.  
  16. while (matcher.find()) {
  17. if (null != matcher.group(1)) {
  18. System.out.println(matcher.group(1));
  19. }
  20. }
  21. }
  22. }
Success #stdin #stdout 0.11s 52380KB
stdin
Standard input is empty
stdout
xyz(d.e)
'f'
'g'
'h'
'i'
abc('p/q')
'r'