NAnt SDK Documentation - v0.92 |

# StringFunctions.Replace Method

Returns a string corresponding to the replacement of a given string with another in the specified string.

[Visual Basic]
<Function(Name:="replace")>
Public Shared Function Replace( _
ByVal str As String, _
ByVal oldValue As String, _
ByVal newValue As String _
) As String
[C#]
[Function(Name="replace")]
public static string Replace(
string str,
string oldValue,
string newValue
);

#### Parameters

str
  input string
oldValue
  A String to be replaced.
newValue
  A String to replace all occurrences of oldValue.

#### Return Value

A String equivalent to str but with all instances of oldValue replaced with newValue.

#### Remarks

This function performs a word (case-sensitive and culture-sensitive) search to find oldValue.

#### Exceptions

Exception Type | Condition
--- | ---
ArgumentException | oldValue is an empty string.

#### Example

    string::replace('testing string', 'test', 'winn') ==> 'winning string'

    string::replace('testing string', 'foo', 'winn') ==> 'testing string'

    string::replace('testing string', 'ing', '') ==> 'test str'

    string::replace('banana', 'ana', 'ana') ==> 'banana'

#### See Also

StringFunctions Class | NAnt.Core.Functions Namespace