Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
Namespace: System.Text.RegularExpressions
Assembly: System.Text.RegularExpressions (in System.Text.RegularExpressions.dll)
Syntax
'Declaration
Public Function Replace ( _
substituteIn As String, _
substitution As String, _
maxOccurances As Integer, _
start As Integer _
) As String
public string Replace(
string substituteIn,
string substitution,
int maxOccurances,
int start
)
public:
String^ Replace(
String^ substituteIn,
String^ substitution,
int maxOccurances,
int start
)
member Replace :
substituteIn:string *
substitution:string *
maxOccurances:int *
start:int -> string
public function Replace(
substituteIn : String,
substitution : String,
maxOccurances : int,
start : int
) : String
Parameters
- substituteIn
Type: System. . :: . .String
The string to search for a match.
- substitution
Type: System. . :: . .String
The replacement string.
- maxOccurances
Type: System. . :: . .Int32
Maximum number of times the replacement can occur.
- start
Type: System. . :: . .Int32
The character position in the input string where the search begins.
Return Value
Type: System. . :: . .String
A new string that is identical to the input string, except that the replacement string takes the place of each matched string.
Remarks
The search for matches starts in the substituteIn string at the position specified by the start parameter. The regular expression is the pattern defined by the constructor for the current Regex object. If maxOccurances is negative, replacements continue to the end of the string. If maxOccurances exceeds the number of matches, all matches are replaced.
The substitution parameter specifies the string that is to replace each match in substituteIn. substitution can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is matched by the test capturing group, if any, followed by the string "b". The * character is not recognized as a metacharacter within a replacement pattern.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.