class PathUtil {

    public String replaceBranch(final String newBranchName,
                                final String uri) {
        final Matcher matcher = branchNameReplacer.matcher(uri);
        return matcher.replaceFirst("$1" + newBranchName.replace("$", "\\$") + "$3");
    }

}