replace


Description:

public string replace (string old, string replacement, int max_tokens = -1)

Replace occurrences of the search string with the replacement string at a maximum of max_tokens

Example: Replace all occurrences of a string:

public static int main (string[] args) {
// Output: ``An apple a day keeps the TARDIS away``
string res = "An apple a day keeps the doctor away".replace ("doctor", "TARDIS");
print ("%s\n", res);
return 0;
}

valac --pkg glib-2.0 string.replace.vala

Parameters:

old

The value being searched for

replacement

The replacement value that replaces old values.

max_tokens

The maximum number. If this is less than 0, the string will be replaced completely.

Returns:

a string with the replaced values.