class EvaluationPhaseFilterFunctions {

    public static FunctionalSet<ValueTuple> includeRegex(Object fieldValue, String regex) {
        FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
        if (fieldValue != null
                        && (JexlPatternCache.getPattern(regex).matcher(ValueTuple.getStringValue(fieldValue)).matches() || (JexlPatternCache.getPattern(regex)
                                        .matcher(ValueTuple.getNormalizedStringValue(fieldValue)).matches() && !regex.matches(CASE_SENSITIVE_EXPRESSION)))) {
            matches = FunctionalSet.singleton(getHitTerm(fieldValue));
        }
        return matches;
    }

}