Whatever message this page gives is out now! Go check it out!
REReplace(string,regex,substring,[scope])Parameter | Description |
string | A string or a variable that contains one. String within which to search. |
regex | Regular expression to replace. The search is case sensitive. |
substring | A string or a variable that contains one. Replaces reg_expression. Also takes a callback function as an argument. |
scope |
|
<cfscript>
writeOutput(REReplace("CABARET","C|B","G","ALL") & "<br/>")
writeOutput(REReplace("CABARET","C|B","G","ALL") & "<br/>")
writeOutput(REReplace("CABARET","[A-Z]","G","ALL") & "<br/>")
writeOutput(REReplace("CABARET","[A-Z]","G","ALL") & "<br/>")
writeOutput(REReplace("I love jellies","jell(y|ies)","cookies") & "<br/>")
writeOutput(REReplace("I love jellies","jell(y|ies)","cookies") & "<br/>")
writeOutput(REReplace("I love jelly","jell(y|ies)","cookies") & "<br/>")
writeOutput(REReplace("I love jelly","jell(y|ies)","cookies") & "<br/>")
</cfscript><cfscript>
myStr = "PROSPER";
outStr = reReplace( myStr, "P|S", function (transform, position, original, Count){
writeOutput(Count)
return "G";
}, "all");
writeoutput(outStr);
</cfscript><cfscript>
myStr = "PROSPER";
outStr = reReplace( myStr, "P|S", function (transform, position, original, Count){
writeOutput(Count)
return "G";
}, "one");
writeoutput(outStr);
</cfscript>