How to match the whole ("SOMETHING","SOMETHING","SOMETHING",...) expression(only quoted upper case A-Z characters without special symbols and whitespaces) and group quoted strings?
("JOY","SAD") - should match
("JOY","sad") - shouldn't match
("JOY",0) - shouldn't match
("JOY","'")- shouldn't match
("JOY",SAD) - shouldn't match
("JOY","") - shouldn't match
("") - shouldn't match
("0") - shouldn't match
(a) - shouldn't match
Tried this regex expression - it groups it correct but still some examples are passed:
\((\"([A-Z]+)*\")\)
UPDATE
Used suggested regex by @anubhava a little bit modifying match group - (?:\(|\G(?!^),)\"([A-Z]+)\"(?=(?:,\"[A-Z]+\")*\)$)
in java Pattern.compile:
Pattern.compile("(?:^\\(|\\G(?!^),)(\\\"[A-Z]+\\\")(?=(?:,\\\"[A-Z]+\\\")*\\)$)")
However, why the same regex expression cannot be matched if I use java Patter.compile() method?