Strings.Replace Method
Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public static string Replace( string Expression, string Find, string Replacement, int Start, int Count, CompareMethod Compare )
Parameters
- Expression
- Type: System.String
Required. String expression containing substring to replace.
- Find
- Type: System.String
Required. Substring being searched for.
- Replacement
- Type: System.String
Required. Replacement substring.
- Start
- Type: System.Int32
Optional. Position within Expression where substring search is to begin. If omitted, 1 is assumed.
- Count
- Type: System.Int32
Optional. Number of substring substitutions to perform. If omitted, the default value is –1, which means "make all possible substitutions."
- Compare
- Type: Microsoft.VisualBasic.CompareMethod
Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings for values.
Return Value
Type: System.StringIf Find is zero-length or Nothing, Replace returns copy of Expression. If Replace is zero-length, Replace returns copy of Expression with no occurrences of Find. If Expression is zero-length or Nothing, or Start is greater than length of Expression, Replace returns Nothing. If Count is 0, Replace returns copy of Expression.
For more detailed information, see the Visual Basic topic Replace Function (Visual Basic).
The return value of the Replace function is a string that begins at the position specified by Start and concludes at the end of the Expression string, with the substitutions made as specified by the Find and Replace values.
The Compare argument can have the following values.
Constant | Description |
|---|---|
Binary | Performs a binary comparison |
Text | Performs a textual comparison |
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.