Calc REPLACE function

REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string.

Help CentreFunctions & Formulas

For a full list of available calculation functions, please read What calculation functions are supported.

This article describes the formula syntax and usage of the REPLACE function.


Description

REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string.


Syntax

REPLACE(old_text, start_num, num_chars, new_text)

The REPLACE function syntax has the following arguments:

  • old_text - Required. Text in which you want to replace some characters.
  • start_num - Required. The position of the character in old_text that you want to replace with new_text.
  • num_chars - Required. The number of characters in old_text that you want REPLACE to replace with new_text.
  • new_text - Required. The text that will replace characters in old_text.
  • Example

    FormulaDescriptionResult
    =REPLACE(A2, 6, 5, "*")Replaces five characters in abcdefghijk with a single * character, starting with the sixth character (f).abcde*k
    =REPLACE(A3, 3, 2, "10")Replaces the last two digits (09) of 2009 with 10.2010
    =REPLACE(A4, 1, 3, "@")Replaces the first three characters of 123456 with a single @ character.@456

    Errors

    For a full list of formula errors, please read Formula errors.


    Related functions

    See it working on your own data

    Everything documented here ships with the platform – try the document tools free, or go live in 7 days.