Method
Replace
Warning
This item was deprecated in version 2022r1. Please use String.Replace as a replacement.
Usage
result=sourceVariable.Replace(oldString, newString)
Part |
Type |
Description |
---|---|---|
result |
A copy of sourceVariable with any changes made by the Replace function. |
|
sourceVariable |
The original string. |
|
oldString |
The characters to be replaced. |
|
newString |
The replacement characters. |
Notes
Replaces the first occurrence of oldString in sourceString with newString. Replace is case-insensitive.
If newString is an empty string (""), the Replace function deletes the first occurrence of the oldString in the sourceString.
If oldString is an empty string (""), the Replace function returns an unchanged copy of the sourceString.
Sample code
Below are some examples that show the results of the Replace function:
Var result As String
Var source As String = "the quick fox"
result = source.Replace("fox", "rabbit") ' returns "The quick rabbit"
result = source.Replace("f", "b") ' returns "The quick box"
result = source.Replace("quick ", "") ' returns "The fox"
Compatibility
All project types on all supported operating systems.
See also
ReplaceAll, ReplaceLineEndings functions.