Replace part of string

Syntax

s.replace(ss [from] [nc])

 

Parameters

s - str variable.

ss - replacement string. Can be string or numeric expression.

from - where to do the replacement. 0-based character index in s. Default: 0.

nc - number of characters to replace. Default: -1 (all characters at right from from).

 

Remarks

Replaces range of characters in s.

 

Example

str s = "one two three"
s.replace("four" 4 3)
 now s is "one four three"