return new CompiledPattern(Pattern.compile(regex.toString()), varNames);
/** * Tries to process the data against the compiled expression. If successful, the map will contain * the matched data, using the specified variable names in the original pattern. * * @param map The map of variables * @param data The data to match * @param expr The compiled pattern * @return True if matched, false if not matched, the data was null, or the data was an empty string */ public boolean match(Map<String, String> map, String data, CompiledPattern expr) { if (data != null && data.length() > 0) { Matcher matcher = expr.getPattern().matcher(data); if (matcher.matches()) { for (int x=0; x<expr.getVariableNames().size(); x++) { map.put(expr.getVariableNames().get(x), matcher.group(x+1)); } return true; } } return false; }