001    
002    package railo.runtime.functions.string;
003    
004    import org.apache.oro.text.regex.MalformedPatternException;
005    
006    import railo.runtime.PageContext;
007    import railo.runtime.exp.ExpressionException;
008    import railo.runtime.exp.FunctionException;
009    import railo.runtime.ext.function.Function;
010    import railo.runtime.regex.Perl5Util;
011    
012    /**
013     * Implements the Cold Fusion Function refindnocase
014     */
015    public final class REFindNoCase implements Function {
016            
017            public static Object call(PageContext pc , String regExpr, String str) throws ExpressionException {
018                    return call(pc,regExpr,str,1,false);
019            }
020            public static Object call(PageContext pc , String regExpr, String str, double start) throws ExpressionException {
021                    return call(pc,regExpr,str,start,false);
022            }
023            public static Object call(PageContext pc , String regExpr, String str, double start, boolean returnsubexpressions) throws ExpressionException {
024                    try {
025                            if(returnsubexpressions)
026                                    return Perl5Util.find(regExpr,str,(int)start,false);
027                            return new Double(Perl5Util.indexOf(regExpr,str,(int)start,false));
028                    } catch (MalformedPatternException e) {
029                            throw new FunctionException(pc,"reFindNoCase",1,"regularExpression",e.getMessage());
030                    }
031            }
032    }