The Replace function replaces a specified substring within a
specified string with a new specified substring and returns the
modified string.
Comparison Constants
| CONSTANT | VALUE | DESCRIPTION |
| VBBinaryCompare | 0 | Binary comparison |
| VBTextCompare | 1 | Text Comparison |
| VBDataBaseCompare | 2 | Compare information inside database |
<% =Replace("How now brown cow?", "brown", "purple") %>How now purple cow?<% =Replace("How now brown cow?", "brown", "purple", 7) %>w purple cow?Note that the portion of the string to the left of the start position will be discarded.
<% =Replace("red blue red-blue redblue bluered", "blue", "purple", 1, 3) %>red purple red-purple redpurple bluered<% =Replace("red blue red-blue redblue bluered", "BLUE", "PURPLE", 1, 3, 0) %>red blue red-blue redblue blueredIn the example, by using VBBinaryCompare, or 0, for the Compare argument, all upper/lower case differences are obeyed in both the search and replace.
<% =Replace("red blue red-blue redblue bluered", "BLUE", "PURPLE", 1, 3, 1) %>red PURPLE red-PURPLE redPURPLE blueredIn the example, by using VBTextCompare, or 1, for the Compare argument, all upper/lower case differences are ignored in the search and obeyed in the replace.