final StringBuffer token = new StringBuffer(); for (int i = 0; i < expr.length(); i++) { if (Character.isLetterOrDigit(expr.charAt(i))) token.append(expr.charAt(i)); else break;
CharSequence start = ""; if (matchAll) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < expr.length(); i++) { if (Character.isLetterOrDigit(expr.charAt(i))) buf.append(expr.charAt(i)); else break; } start = buf;
    private NodeSet getNodesRegexp(XQueryContext context, DocumentSet docs, NodeSet contextSet,            String expr, int type) throws TerminatedException {        //Return early        if (expr == null)            return null;        if (stoplist.contains(expr))            return null;        //TODO : case conversion should be handled by the tokenizer -pb        expr = expr.toLowerCase();        // if the regexp starts with a char sequence, we restrict the index scan to entries starting with        // the same sequence. Otherwise, we have to scan the whole index.        final StringBuffer token = new StringBuffer();        for (int i = 0; i < expr.length(); i++) {            if (Character.isLetterOrDigit(expr.charAt(i)))                token.append(expr.charAt(i));            else                break;        }        try {            TermMatcher comparator = new RegexMatcher(expr, type, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);            return getNodes(context, docs, contextSet, comparator, token);        } catch (EXistException e) {            return null;        }    }