ColdFusion 9.0 Resources |
REReplaceDescriptionUses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case sensitive. ReturnsIf the scope parameter is set to one, returns a string with the first occurrence of the regular expression replaced by the value of substring. If the scope parameter is set to all, returns a string with all occurrences of the regular expression replaced by the value of substring. If the function finds no matches, it returns a copy of the string unchanged. HistoryColdFusion MX: Added supports for the following special codes in a replacement substring, to control case conversion:
For more information on new features, see REFind. Parameters
UsageFor details on using regular expressions, see Using Regular Expressions in Functions in the Developing ColdFusion Applications. Example<p>The REReplace function returns <i>string</i> with a regular expression replaced with <i>substring</i> in the specified scope. Case-sensitive search. <p>REReplace("CABARET","C|B","G","ALL"): <cfoutput>#REReplace("CABARET","C|B","G","ALL")#</cfoutput> <p>REReplace("CABARET","[A-Z]","G","ALL"): <cfoutput>#REReplace("CABARET","[A-Z]","G","ALL")#</cfoutput> <p>REReplace("I love jellies","jell(y|ies)","cookies"): <cfoutput>#REReplace("I love jellies","jell(y|ies)","cookies")# </cfoutput> <p>REReplace("I love jelly","jell(y|ies)","cookies"): <cfoutput>#REReplace("I love jelly","jell(y|ies)","cookies")#</cfoutput> |