Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 1.1
.NET Framework
Reference
Regex Class
Methods
Replace Method
 Replace Method (String, String, Int...
.NET Framework Class Library
Regex.Replace Method (String, String, Int32)

Replaces up to a specified number of occurrences of a pattern defined by the regular expression specified in the Regex constructor with a specified replacement string, starting at the first character in the input string.

[Visual Basic]
Overloads Public Function Replace( _
   ByVal input As String, _
   ByVal replacement As String, _
   ByVal count As Integer _
) As String
[C#]
public string Replace(
 string input,
 string replacement,
 int count
);
[C++]
public: String* Replace(
 String* input,
 String* replacement,
 int count
);
[JScript]
public function Replace(
   input : String,
 replacement : String,
 count : int
) : String;

Parameters

input
String to modify.
replacement
The replacement string.
count
The maximum number of times the replacement can occur.

Return Value

The modified character string.

Remarks

If count is negative, replacements continue to the end of the string.

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

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker