Description:
Returns string in which a specified substring has been replaced with another substring a specified number of times.
In the PROMOTIC system it is better to use the Pm.StringReplace method.
Syntax:
String Replace(String expression, String find, String replacewith, [Integer start], [Integer count], [Integer compare])
Parameters:
expression | (String) Text string containing substring to replace |
find | (String) Substring being searched for |
replacewith | (String) Replacement substring |
start | [optional] (Integer) Position within expression where substring search is to begin.
If not set, then 1 is assumed. |
count | [optional] (Integer) Specifies the number of substring substitutions to perform.
If not set, then the value is -1 (means make all possible substitutions). |
compare | [optional] (Integer) Numeric value specifies the kind of comparison to use when evaluating substrings.
If not set, then a binary comparison is performed.
vbBinaryCompare - perform a binary comparison
vbTextCompare - perform a textual comparison |
---|
Return value:
Text string, with substitutions made, that begins at the position specified by "start" and concludes to the end of the "expression" string. It is not a copy of the original string from "start" to the end. Special cases:
empty string ("") - if
"expression" is empty string or if
"start" >
Len(
"expression").
copy of "expression" - if "find" is empty string or if "count" is 0.
Copy of expression with all occurrences of "find" removed - if "replacewith" is empty string.
Example:
VBScriptSelect and copy to clipboard
Dim sString
' Binary comparison from beginning of the string. Returns a value "XXYXXPXXY"
sString = Replace("XXpXXPXXp", "p", "Y")
' Textual comparison starting at 3rd position. Returns a value "YXXYXXY"
sString = Replace("XXpXXPXXp", "p", "Y", 3, -1, 1)