Export (0) Print
Expand All

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

.NET Framework 1.1

Replaces all occurrences of a character pattern defined by a specified regular expression with a replacement character string starting at the first character. Options can be specified to modify matching behavior and a MatchEvaluator delegate is called at each match to evaluate the replacement.

[Visual Basic]
Overloads Public Shared Function Replace( _
   ByVal input As String, _
   ByVal pattern As String, _
   ByVal evaluator As MatchEvaluator, _
   ByVal options As RegexOptions _
) As String
[C#]
public static string Replace(
 string input,
 string pattern,
 MatchEvaluator evaluator,
 RegexOptions options
);
[C++]
public: static String* Replace(
 String* input,
 String* pattern,
 MatchEvaluator* evaluator,
 RegexOptions options
);
[JScript]
public static function Replace(
   input : String,
 pattern : String,
 evaluator : MatchEvaluator,
 options : RegexOptions
) : String;

Parameters

input
The string to modify.
pattern
The regular expression pattern to match.
evaluator
The MatchEvaluator which evaluates replacement at each step.
options
A bitwise OR combination of RegexOption enumeration values.

Return Value

The modified character string.

Remarks

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.

Requirements

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

Show:
© 2014 Microsoft