Replace function
Syntax
Replace(oldtext, start, num_chars, newtext)
Description
Use the Replace function to replace a specified number of characters in a string.
Parameters
| Parameter | Description |
|---|---|
|
oldtext |
A String value, part of which is to be replaced. |
|
start |
A Number designating the position in oldtext from which to start replacing characters. |
|
num_chars |
A Number, specifying how many characters to replace in oldtext. |
|
newtext |
A String value that replaces num_chars characters. |
Returns
Returns a String value in which specific characters in oldtext are replaced with newtext.
Example
After the following statement &NEWDATESTR equals "1997":
&NEWDATESTR =Replace("1996",3,2,"97");
If this example, where the number of characters in newtext is less than num_chars, &SHORTER equals "txtx":
&SHORTER = Replace("txt123",4,3,"x");
In this example, where the number of characters in newtext is greater than num_chars, &LONGER equals "txtxxxx":
&LONGER = Replace("txt123",4,3,"xxxx");
Related Topics