Replace Procedure

Replaces all occurrences of a search phase in a string with a replacement phrase.
Declaration
function Replace(
haystack as String, needle as String, replacement as String
) as String

Parameters

Return value

String — The haystack string with all occurrences of needle replaced with replacement.

Possible error codes

Example

Code
print "1:"; Replace("aaa", "a", "bb")
print "2:"; Replace("aaa", "aa", "bb")
print "3:"; Replace("", "a", "b")
print "4:"; Replace("aaa", "a", "aa")
print "5:"; Replace("aaaa", "aa", "a")
Output
1:bbbbbb
2:bba
3:
4:aaaaaa
5:aa