Java: Regex not matching
问题 I have comma separated string values. Every string may contain characters or numbers along with '-' or '/' or '.'. My code looks like: final String VALUES_REGEX = "^\\{([0-9a-zA-Z\\-\\_\\.])+,*([0-9a-zA-Z\\-\\_\\.])*\\}$"; final Pattern REGEX_PATTERN = Pattern.compile(VALUES_REGEX); final String values = "{df1_apx.fhh.irtrs.d.rrr, ffd1-afp.farr.d.rrr.asgd}"; final Matcher matcher = REGEX_PATTERN.matcher(values); if (null != values && matcher.matches()) { // further logic } ... ... Here if