Wednesday, March 18, 2009

Replace with coldfusion

Replace

Description (http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000611.htm)

Replaces occurrences of substring1 in a string with substring2, in a specified scope. The search is case-sensitive.

Returns

The string, after making replacements.

Parameters

Parameter

Description

string

A string or a variable that contains one. String in which to search.

substring1

A string or a variable that contains one. String for which to search

substring2

String that replaces substring1

scope

  • one: replaces the first occurrence (default)
  • all: replaces all occurrences

Usage

To remove a string, specify the empty string ("") as substring2.

You do not need to escape comma characters in strings. For example, the following code deletes the commas from the sentence:

replace("The quick brown fox jumped over the lazy cow, dog, and cat.",",","","All")

1 comment:

  1. In Replace function the search is case-sensitive.Can you give any function that I can use for case insensitive replacement.Also the function that allow me to replace only if its at starting.Thanks for the detailed function information that you provided above

    ReplyDelete