Substitute

Qubes 6.5

Replaces a sub-string of a character string.

Syntax

Substitute(string, old, new[, occurrence])
Substitue(string, old, new[, occurrence])
string = string in which to perform the substitution
old = sub-string to replace
new = replacement sub-string
occurrence = index of the occurrence you want to replace (all if absent)

Remarks

The occurrence parameter is interpreted as follows:

  • if not specified or zero, every occurrence will be replaced;
  • if specified and not zero, the indicated occurrence will be replaced:
    • if positive, the occurrences will be counted from the beginning (the first occurrence has an index of 1),
    • if negative, the occurrences will be counted from the end (the last occurrence has an index of -1).

Examples

Substitute("banana", "an", "o") = "booa"
Substitute("banana", "an", "o", 1) = "boana"
Substitute("banana", "an", "o", 2) = "banoa"
Substitute("banana", "an", "o", 3) = "banana"
Substitute("banana", "an", "o", -1) = "banoa"

Classification

Strings