LOG.debug("Using xs:string index for fn:matches. Regex: " + pattern);
    private Sequence evalWithIndex(Sequence contextSequence, Item contextItem, Sequence input) throws XPathException {        String pattern = translateRegexp(getArgument(1).eval(contextSequence, contextItem).getStringValue());        NodeSet nodes = input.toNodeSet();                int flags = 0;         boolean caseSensitive = true;        if(getSignature().getArgumentCount() == 3) {            String flagsArg = getArgument(2).eval(contextSequence, contextItem).getStringValue();            caseSensitive = flagsArg.indexOf('i') < 0;            flags = parseFlags(flagsArg);        }                // get the type of a possible index		int indexType = nodes.getIndexType();		if(Type.subTypeOf(indexType, Type.STRING)) {		    DocumentSet docs = nodes.getDocumentSet();		    try {				return context.getBroker().getValueIndex().match(docs, nodes, pattern, 						DBBroker.MATCH_REGEXP, flags, caseSensitive);			} catch (EXistException e) {				throw new XPathException(getASTNode(), e.getMessage(), e);			}		} else {		    ExtArrayNodeSet result = new ExtArrayNodeSet();		    for(Iterator i = nodes.iterator(); i.hasNext(); ) {		        NodeProxy node = (NodeProxy) i.next();		        if(match(node.getStringValue(), pattern, flags))		            result.add(node);		    }		    return result;		}    }