This documentation is archived and is not being maintained.

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

.NET Framework 1.1

Replaces all occurrences of a pattern defined by a specified regular expression with a specified replacement character string, starting at the first character in the input string. Options can be specified to modify matching behavior.

[Visual Basic]
Overloads Public Shared Function Replace( _
   ByVal input As String, _
   ByVal pattern As String, _
   ByVal replacement As String, _
   ByVal options As RegexOptions _
) As String
public static string Replace(
 string input,
 string pattern,
 string replacement,
 RegexOptions options
public: static String* Replace(
 String* input,
 String* pattern,
 String* replacement,
 RegexOptions options
public static function Replace(
   input : String,
 pattern : String,
 replacement : String,
 options : RegexOptions
) : String;


The string to modify.
The regular expression pattern to match.
The replacement string.
A bitwise OR combination of RegexOption enumeration values.

Return Value

The modified string.


The static Replace methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Replace. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.


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