ZennoLab Assemblies Documentation
Replace Method
Example 

Type: System.String

The source string.

Type: System.String

The string to be replaced.

Type: System.String

The string to replace occurrences of find.

Type: System.String

The type of the search find. It can have the following values: Text or Regex.

Type: System.String

The type of the performance of replacing in String object. It can have the following values: All, First, Last, Number or Range.

Type: System.String

The additional parameter for search. This parameter applies only for Number and Range values of take. Default value is empty string. In Number case it must be number of the occurrence in string value, in Range case it must be the range of the occurrences.

Returns a new string in which occurrences of a specified string in the current instance are replaced with another specified string.
Syntax
public static string Replace( 
   string sourceString,
   string find,
   string replace,
   string searchType,
   string take,
   string parameters
)

Parameters

sourceString

Type: System.String

The source string.

find

Type: System.String

The string to be replaced.

replace

Type: System.String

The string to replace occurrences of find.

searchType

Type: System.String

The type of the search find. It can have the following values: Text or Regex.

take

Type: System.String

The type of the performance of replacing in String object. It can have the following values: All, First, Last, Number or Range.

parameters

Type: System.String

The additional parameter for search. This parameter applies only for Number and Range values of take. Default value is empty string. In Number case it must be number of the occurrence in string value, in Range case it must be the range of the occurrences.

Return Value

Type: System.String

A string that is equivalent to the current string except that instances of find are replaced with replace.

Remarks
If replace is null, all occurrences of find are removed.
Example
The following example shows call the replace method.
// replace "this" in string to "new value"
string newString = Macros.TextProcessing.Replace("replace this to new value", "this", "new value", "Text", "First");
// replace "this" in string to "new value"
$newString = Macros::TextProcessing::Replace("replace this to new value", "this", "new value", "Text", "First");
Requirements

Target Platforms: Desktop: Windows XP SP3 and older. Server: Windows Server 2003 and older.

See Also

Reference

TextProcessing Class
TextProcessing Members
RemoveDuplicates Method
Trim Method

Send Feedback