/** * Does the given argument match the pattern using default options? * @param argument the string to match against * @return true if the pattern matches * @throws BuildException on error */ @Override public boolean matches(final String argument) throws BuildException { return matches(argument, MATCH_DEFAULT); }
/** * Returns a Vector of matched groups found in the argument. * * <p>Group 0 will be the full match, the rest are the * parenthesized subexpressions</p>. * * @param input the string to match against * @param options the regex options to use * @return the vector of groups * @throws BuildException on error */ @Override public Vector<String> getGroups(final String input, final int options) throws BuildException { if (!matches(input, options)) { return null; } final Vector<String> v = new Vector<>(); final MatchResult mr = matcher.getMatch(); final int cnt = mr.groups(); for (int i = 0; i < cnt; i++) { String match = mr.group(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.add(match); } return v; }