Java Regex inconsistent groups
问题 Please Refer to following question on SO: Java: Regex not matching My Regex groups are not consistent. My code looks like: public class RegexTest { public static void main(String[] args) { // final String VALUES_REGEX = "^\\{([0-9a-zA-Z\\-\\_\\.]+)(?:,\\s*([0-9a-zA-Z\\-\\_\\.]*))*\\}$"; final String VALUES_REGEX = "\\{([\\w.-]+)(?:, *([\\w.-]+))*\\}"; final Pattern REGEX_PATTERN = Pattern.compile(VALUES_REGEX); final String values = "{df1_apx.fhh.irtrs.d.rrr, ffd1-afp.farr.d.rrr.asgd, ffd2