| Contents > CFML Reference > ColdFusion Functions > REReplace |
|
|
|
|
||
Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive.
If the scope attribute is set to one, returns a string with the first occurrence of the regular expression replaced by the value of substring.
If the scope attribute 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.
REReplace(string, reg_expression, substring [, scope ])
REFind, Replace, ReplaceList, REReplaceNoCase
ColdFusion MX: Added supports for the following special codes in a replacement substring, to control case conversion:
For more information on new features, see REFind.
Parameter |
Description |
|---|---|
string |
A string or a variable that contains one. String within which to search. |
reg_expression |
Regular expression to replace. The search is case-sensitive. |
substring |
A string or a variable that contains one. Replaces |
scope |
|
For details on using regular expressions, see Using Regular Expressions in Functions in Developing ColdFusion MX Applications.
<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>
|
|
||
| Contents > CFML Reference > ColdFusion Functions > REReplace |
|
|
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
"), but I can't make that work. theowd81 said on Dec 21, 2004 at 11:23 PM :
This example replace content of a tag to lowercase.lethepsu said on Jan 21, 2005 at 1:42 PM :
<cfset thisdata = REReplace(thisdata, "<(.*)[^>]>","<>", "ALL")>
It would be nice if you guys actually showed the output of the codeSorry,_that_nickname said on Dec 14, 2005 at 6:16 PM :
snippets you provide. I understand that's not feasible if you're doing
something that requires user input, but for this example if would be very
helpful. It's something that's lacking throughout LiveDocs, as far as I've
seen.
backslash-digit is also interpreted in the replacement string. In fact,
I believe this is the only way to use the case switches meaningfully.
It appears to be undocumented.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functa71.htm
Comments
No screen name said on Oct 19, 2004 at 7:38 AM : No screen name said on Dec 9, 2004 at 11:24 AM :