StringFunctions.

Replace(string, string, string) Method

Summary

Returns a string corresponding to the replacement of a given string with another in the specified string.
Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Functions
Containing Type
StringFunctions

Syntax

[Function("replace")]
public static string Replace(string str, string oldValue, string newValue)

Examples

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'

Remarks

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

Attributes

Type Description
FunctionAttribute Indicates that the method should be exposed as a function in NAnt build files.

Parameters

Name Type Description
str string input string
oldValue string A string to be replaced.
newValue string A string to replace all occurrences of oldValue.

Return Value

Type Description
string A string equivalent to str but with all instances of oldValue replaced with newValue.