replace
Description
The replace() function replaces elements in a list, thereby creating a new list. The list elements in the specified range are deleted and those that are specified by the string arguments are inserted in their place. If replacement arguments are not supplied, then the appropriate elements are deleted without being replaced.
Syntax
result = replace (list1, index1, index2, list-or-string1 [, list-or-string2, ...]);
Arguments
list1 | Required. The list from which list elements are removed, and optionally, replaced by new elements |
index1 | Required. The first element in the range of elements to delete or replace. |
index2 |
Required. The last element in the range of elements to delete or replace. |
string1..n | Optional. The list(s) or character string(s) that will replace the list elements that are being deleted. |
Return Values
result | Contains the new list that is created by deleting or replacing elements from the original list. |
list1 = {"Adm1", "Adm2", "Adm3", "Adm4"}; result = replace (list1, 2, 3, "SysAdm1", "SysAdm2");
In this example, result contains the following list:
{"Adm1", "Adm2", "SysAdm1", "SysAdm2"}
For more information, see the following: