Name
ReplaceStr -- replaces a substring with another string
Synopsis
var$ = ReplaceStr(s$, search$, replace$[, cs, startpos, encoding])
Function
Searches for search$ in s$ and replaces all occurrences of search$ with replace$. The optional argument cs turns case sensitivity on (True) or off (False). Defaults to True.

Starting with Hollywood 4.5, you can also specify a starting position for the search in the optional argument startpos. This position needs to be specified in characters, not in bytes. Specifying 0 as the starting position means search and replace from the beginning of the string. This is also the default.

The optional encoding parameter can be used to set the character encoding to use. This defaults to the default string encoding set using SetDefaultEncoding(). See Character encodings for details.

Inputs
s$
string to search for search$
search$
string to search for
replace$
string replacement for search$
cs
True for case sensitivity (default), False for no case sensitivity
startpos
optional: starting position of the search and replace operation in characters (defaults to 0) (V4.5)
encoding
optional: character encoding to use (defaults to default string encoding) (V7.0)
Results
var$
resulting string
Example
test$ = "Hello World!"
test$ = ReplaceStr(test$, "World", "People")
Print(test$)
This will print "Hello People!" to the screen.

Show TOC