REPLACE (OriginalText, StartIndex, Length, NewText) REPLACE (OriginalText; StartIndex; Length; NewText)

OriginalText

Text Text

The original text string.

StartIndex

Number Number

The position in the OriginalText text string where the NewText text string should be inserted.

Length

Number Number

The number of characters that should be replaced.

NewText

Text Text

The replacement text string.

Returns

Text Text

The resulting text string.

Replaces a part of a text string with a different text string and returns the result. REPLACE ("one two three", 5, 3, "2") REPLACE ("one two three"; 5; 3; "2") returns "one 2 three". The second parameter, 5, is the position where "two" starts, and the third parameter, 3, is the length of the text string to replace, "two". The fourth parameter is the replacement text string.

Use SUBSTITUTE to replace text where the text to be replaced is known, but not its position. Use REGEXREPLACE to replace text using powerful regular expressions which find the text to replace.

Examples

REPLACE ("one two three", 5, 3, "2")
REPLACE ("one two three"; 5; 3; "2")

Returns "one 2 three".

REPLACE ("one two three", 5, 3, { "2", "TWO" })
REPLACE ("one two three"; 5; 3; { "2"; "TWO" })

Returns the array { "one 2 three", "one TWO three" }{ "one 2 three"; "one TWO three" }.

fxEngine Shell Want this in your own terminal? A standalone version is coming. Get notified.
Loading fxEngine Shell