/** * Returns a Vector of matched groups found in the argument * using default options. * * <p>Group 0 will be the full match, the rest are the * parenthesized subexpressions</p>. * * @param argument the string to match against * @return the vector of groups * @throws BuildException on error */ @Override public Vector<String> getGroups(final String argument) throws BuildException { return getGroups(argument, MATCH_DEFAULT); }
/** * 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); }
/** * 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(final String input, final int options) throws BuildException { return matcher.contains(input, getCompiledPattern(options)); }
/** * Get a compiled representation of the regexp pattern * @param options the options * @return the compiled pattern * @throws BuildException on error */ protected Pattern getCompiledPattern(final int options) throws BuildException { try { // compute the compiler options based on the input options first return compiler.compile(pattern, getCompilerOptions(options)); } catch (final Exception e) { throw new BuildException(e); } }
/** * 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; }