This documentation is archived and is not being maintained.

Regex.Replace Method (String, MatchEvaluator, Int32, Int32)

.NET Framework 1.1

Replaces up to a specified number of occurrences of a pattern specified in the Regex constructor with a replacement string, starting at a specified character position in the input string. A MatchEvaluator delegate is called at each match to evaluate the replacement.

[Visual Basic]
Overloads Public Function Replace( _
   ByVal input As String, _
   ByVal evaluator As MatchEvaluator, _
   ByVal count As Integer, _
   ByVal startat As Integer _
) As String
public string Replace(
 string input,
 MatchEvaluator evaluator,
 int count,
 int startat
public: String* Replace(
 String* input,
 MatchEvaluator* evaluator,
 int count,
 int startat
public function Replace(
   input : String,
 evaluator : MatchEvaluator,
 count : int,
 startat : int
) : String;


The string to be modified.
The MatchEvaluator which evaluates replacement at each step.
The maximum number of times the replacement will occur.
The character position in the input string where the search will begin.

Return Value

The modified character string.


The MatchEvaluator type is a delegate that takes a single Match as input and returns a string. It is declared as follows:

public delegate String RegexMatchEvaluator(Match match);The delegate is called once per match during a replace.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Regex Class | Regex Members | System.Text.RegularExpressions Namespace | Regex.Replace Overload List