public ControllerRequest(Class<? extends Controller> controllerClass, Matcher matchedUrl) { this.controllerClass = controllerClass; if (matchedUrl.groupCount() > 0) { List<String> argsList = new ArrayList<String>(matchedUrl.groupCount()); for (int i = 1; i <= matchedUrl.groupCount(); i++) { argsList.add(matchedUrl.group(i)); } this.args = argsList; } else { this.args = new ArrayList<String>(0); } }
@Test public void findsMultipleGroups() { Pattern pattern = compile("\\w* "); Matcher matcher = pattern.matcher("this is a sentance"); log.info("GroupCount: " + matcher.groupCount()); while (matcher.find()) { log.info("Found group : [" + matcher.group().trim() + "]"); } }