Contact

SUBSTITUTE Function (Gnumeric)

Text Beginner Gnumeric

Learn the SUBSTITUTE function in Gnumeric: Substitutes new text for old text in a string.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

The SUBSTITUTE function in Gnumeric is used for this task: Substitutes new text for old text in a string. Replace matching text wherever it appears.

This guide explains how to read the formula, reproduce a concrete example, interpret its result and recognize common input mistakes.

Availability and version history

  • Introduced: Documented by 1.12.62; original introduction not established.
  • Availability: Supported in Gnumeric 1.12.62, based on the function-specific registration.
  • Scope: Desktop; the fn-string function module must be included and enabled.
  • Checked: Fresh official 1.12.57 source and bounded 1.12.57 native checks on October 17, 2026. Retained 1.12.62 availability registration is separate; no 1.12.62 runtime claim. Last functioning release was not established.

Syntax and arguments

=SUBSTITUTE(text,old,new,[num])

text is the original string, old the substring to replace, and new the replacement string. The first three arguments are required. Omit num to replace all matching occurrences; specify a positive integer num to replace only that numbered occurrence. Matching is case-sensitive and literal, not a regular expression or wildcard search. The result is new text; the original input cell is unchanged.

The inspected implementation rejects num ≤ 0 with #VALUE!. A positive fractional num is converted to an integer internally, so supply a whole-number occurrence rather than relying on surprising fractional cases.

Worked example

=SUBSTITUTE("blue car","blue","red")

Expected result: red car.

Why it works: Replace matching text wherever it appears.

All matches versus one occurrence

Formula Expected result
=SUBSTITUTE("a-a-a","a","X") X-X-X
=SUBSTITUTE("a-a-a","a","X",2) a-X-a
=SUBSTITUTE("AbA","a","X") AbA
=SUBSTITUTE("abc","","X") abc
=SUBSTITUTE("abc","a","X",0) #VALUE!

The preserved blue-car example gives red car. In the second row above, occurrences are counted from left to right and only the second a changes. The uppercase A characters in AbA do not match lowercase a. An empty old string leaves the original text unchanged in the inspected source; it does not insert new between every character.

To clean synthetic labels, put north-east, south-east and west-end in A2:A4. =SUBSTITUTE(A2,"-"," ") filled down gives north east, south east and west end. Retain A as the original and use B for cleaned labels so the transformation remains auditable.

Advanced use: staged transformations

Nested substitutions can apply multiple replacements, but order matters because one replacement may create text matched by the next. For example, replacing a with b and then b with c also changes the b characters created by the first step. Use separate columns for intermediate transformations until the intended behavior is clear.

Matches are processed without overlapping the text already consumed. Replacing aa in aaa follows left-to-right non-overlapping matching; do not assume each character starts a separately replaceable match. If the task is to replace a known positional span rather than matching text, choose a positional replacement function and check its argument contract.

Common problems and practical checks

  • If nothing changes, check capitalization, spaces and whether old is actually present.
  • If too many matches change, supply the occurrence number instead of omitting num.
  • An occurrence number beyond the available matches leaves the original text unchanged; it does not invent a new occurrence.
  • Use the empty replacement string to remove matched text deliberately. Removing characters can merge tokens or identifiers, so review the output.
  • Do not use wildcards expecting pattern expansion. A literal * is a literal character here.
  • NEWS records SUBSTITUTE work in 0.19, Unicode and fourth-argument fixes in 1.1.12, and further fixes in 1.5.0/1.7.0. This guide does not infer the first fully functioning historical release.

Documentation and verification