Name
Replace Function
Class
Microsoft.VisualBasic.Strings
Syntax
Replace(expression, find, replace[, _start[,count[,compare]]])
-
expression(required; String) The complete string containing the substring to be replaced
-
find(required; String) The substring to be found by the function
-
replace(required; String) The new substring to replace
findinexpression-
start(optional; Long) The character position in
expressionat which the search forfindbegins-
count(optional; Long) The number of instances of
findto replace-
compare(optional;CompareMethodconstant) The method used to compare
findwithexpression; its value can beCompareMethod.Binary(for case-sensitive comparison) orCompareMethod.Text(for case-insensitive comparison)
Return Value
The return value from Replace depends on the parameters you specify in the argument list, as the following table shows:
|
If |
Return value |
|---|---|
|
|
Zero-length string (“”) |
|
|
Copy of |
|
|
Copy of |
|
|
Zero-length string (“”) |
|
|
Copy of |
Description
Replaces a given number of instances of a specified substring in another string
Rules at a Glance
If
startis omitted, the search begins at the start of the string.If
countis omitted, all instances of the substring afterstartare replaced.CompareMethod.BinaryCompareis case sensitive; that is, Replace matches both character and case, whereasCompareMethod.Textis case ...