Returns a new
Text object who’s value is created by replacing the first instance of the passed
what text with the specified
replacement text. If this
Text object does not contain
what then it returns a new
Text object who’s value is the same as the original’s. The original text is changed to the same value as the return value.
text.replace_first!(what as Text, replace as Text) as Text
Textobject. The text you are searching for
Textobject. The replacement text to use for the first occurrence of
- A new
Textobject. The original text is changed to the value of the returned
var a = "Go Go Gadget!" var b = a.replace_first!("Go", "Yo") print(a) # => "Yo Go Gadget!" print(b) # => "Yo Go Gadget!"