string.replace

This function returns a copy of the input string where <count> non-overlapping instances of <old> are replaced by <new>.

Syntax

string.replace(str, old, new, count)

Arguments

Argument

Type

Description

str

string

Source string

old

string

Old string that needs to be replaced

new

string

New string that replaces the old string

count

int

Number of replacements to be done

If the count is less than 0, there is no limit on the number of replacements that can be done.

Returns

Type

Description

string

String with <count> occurrences of <old> replaced by <new>

Examples

The function string.replace("hello flogo", "flogo", "world", -1) returns hello world.