001 /** 002 * Implements the Cold Fusion Function rereplacenocase 003 */ 004 package railo.runtime.functions.string; 005 006 import org.apache.oro.text.regex.MalformedPatternException; 007 008 import railo.runtime.PageContext; 009 import railo.runtime.exp.ExpressionException; 010 import railo.runtime.exp.FunctionException; 011 import railo.runtime.ext.function.Function; 012 import railo.runtime.regex.Perl5Util; 013 014 public final class REReplaceNoCase implements Function { 015 016 public static String call(PageContext pc , String string, String regExp, String replace) throws ExpressionException { 017 try { 018 return Perl5Util.replace(string,regExp,replace,false,false); 019 } 020 catch (MalformedPatternException e) { 021 throw new FunctionException(pc,"reReplaceNoCase",2,"regularExpression",e.getMessage()); 022 } 023 } 024 025 public static String call(PageContext pc , String string, String regExp, String replace, String scope) throws ExpressionException { 026 try { 027 if(scope.equalsIgnoreCase("all"))return Perl5Util.replace(string,regExp,replace,false,true); 028 return Perl5Util.replace(string,regExp,replace,false,false); 029 } 030 catch (MalformedPatternException e) { 031 throw new FunctionException(pc,"reReplaceNoCase",2,"regularExpression",e.getMessage()); 032 } 033 } 034 }