/** * Does the given argument match the pattern? * @param argument the string to match against * @return true if the pattern matches * @throws BuildException on error */ @Override public boolean matches(String argument) throws BuildException { return matches(argument, MATCH_DEFAULT); }
/** * Does the given argument match the pattern? * @param input the string to match against * @param options the regex options to use * @return true if the pattern matches * @throws BuildException on error */ @Override public boolean matches(String input, int options) throws BuildException { return matches(input, getCompiledPattern(options)); }
/** * 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(String input, int options) throws BuildException { RE reg = getCompiledPattern(options); if (!matches(input, reg)) { return null; } Vector<String> v = new Vector<>(); int cnt = reg.getParenCount(); for (int i = 0; i < cnt; i++) { String match = reg.getParen(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.add(match); } return v; }