world.Replace
Replaces one substring with another
Prototype
BSTR Replace(BSTR Source, BSTR SearchFor, BSTR ReplaceWith, boolean Multiple);
Description
This is a utility function for doing a "find and replace" inside a string.
It is intended to simplify writing scripts that need to replace things.
If "Multiple" is true then all occurences are replaced, otherwise only the first one is replaced.
VBscript example
world.Note world.Replace ("go north, go east", "go", "walk", true)
Jscript example
world.Note(world.Replace("go north, go east", "go", "walk", true));
PerlScript example
$world->Note($world->Replace("go north, go east", "go", "walk", true));
Python example
world.Note(world.Replace("go north, go east", "go", "walk", True))
Lua example
Note(Replace("go north, go east", "go", "walk", true))
Lua notes
The Multiple flag is optional, and defaults to true.
Return value
The source string with one or more occurences of "SearchFor" replaced by "ReplaceWith".
Related topic
See also
| Function | Description |
|---|---|
| FixupEscapeSequences | Converts "escape sequences" like \t to their equivalent codes. |
| FixupHTML | Fixes up text for writing as HTML |
| Trim | Trims leading and trailing spaces from a string |