Java正则表达式-捕获组

    private Set<String> getCodes(String s) {
        Set<String> resultSet = new HashSet<>();
        Matcher matcher = codePattern.matcher(s);
        while (matcher.find()) {
            resultSet.add(matcher.group(1));
        }
        return resultSet;
    }

private static Pattern codePattern = Pattern.compile("\"code\":\"(\\w+)\",");

 

posted @ 2018-05-11 09:41  zslm___  阅读(1164)  评论(0编辑  收藏  举报