Google Sheets
REPLACE function in Google Sheets
Replaces part of a text string with a different text string.
=REPLACE(text, position, length, new_text)REPLACE syntax and parameters
Four arguments, four required.
- textstringRequired
The text, a part of which will be replaced.
- positionnumberRequired
The position where the replacement will begin (starting from 1).
- lengthnumberRequired
The number of characters in the text to be replaced.
- new_textstringRequired
The text which will be inserted into the original text.
REPLACE examples
Formulas you'll actually reuse.
Mask the first four characters of an account number:
=REPLACE(A2, 1, 4, "XXXX")Result
"XXXX5678"Swap the domain after the @ in an email address:
=REPLACE(A2, FIND("@", A2) + 1, LEN(A2), "newdomain.com")Result
"maria.lopez@newdomain.com"
REPLACE in Excel
Same name — your formula ports as-is.
Try REPLACE in the playground
Edit the example — nothing to install.
Preloaded with the REPLACE formula from Example 1 — change anything and watch it respond.
Loading the editor…
Related functions
More ways Google Sheets gets this done.
- ARABICComputes the value of a Roman numeral.TextExcel
- CHARConvert a number into a character according to the current Unicode table.TextExcel
- CLEANReturns the text with the non-printable ASCII characters removed.TextExcel
- CODEReturns the numeric Unicode map value of the first character in the string provided.TextExcel
- CONCATENATEAppends strings to one another.TextExcel
- DOLLARFormats a number into the locale-specific currency format.TextExcel