SUBSTITUTE Function in Apple Numbers: Replace Matching Text
Replace text matches using SUBSTITUTE in Apple Numbers, with whole-string and occurrence-specific examples.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
=SUBSTITUTE("CA-2048-R1","-","") returns CA2048R1. In Apple Numbers, omitting SUBSTITUTE’s fourth argument changes every matching occurrence. Supply that argument to change one selected match instead.
Availability and version history
- Introduced: The original introduction release and date are not established by the checked official sources.
- Availability: Currently documented in Apple’s Formulas and Functions Help 15.4 edition; no final supported-version endpoint is established.
- Scope: Shared iWork function documentation, not a Numbers application build number. Individual historical and client-specific endpoints remain unverified.
- Checked: October 14, 2026, against the official SUBSTITUTE entry. Examples were independently calculated; no native Numbers execution was performed.
Syntax: match text, then choose an occurrence
SUBSTITUTE(source-string, existing-string, new-string, [occurrence])
The first three arguments are required. Apple allows any value for them and permits replacement text of a different length. Brackets above mark an optional argument; do not type them. The optional occurrence must be at least 1. A value beyond the number of matches leaves the source unchanged; omitting it replaces all matches.
An occurrence is a match number, not a character position. REPLACE is the position-based alternative. The Apple entry also supports REGEX search expressions and capture groups, but the reproducible examples here use literal substrings. Do not treat a literal pattern string as an evaluated REGEX expression.
Clean the original catalogue codes
Create Catalog, with seven columns and eight rows. Format A2:A6 as Text. Put Code, No hyphens, Second hyphen removed, Revision change, Original length, Compact length and Removed count in A1:G1.
| Row | A: Code | Expected B | Expected C | Expected D |
|---|---|---|---|---|
| 2 | CA-2048-R1 | CA2048R1 | CA-2048R1 | CA-2048-R4 |
| 3 | US-7312-R2 | US7312R2 | US-7312R2 | US-7312-R2 |
| 4 | CA-0097-R3 | CA0097R3 | CA-0097R3 | CA-0097-R3 |
| 5 | UK-6005-R1 | UK6005R1 | UK-6005R1 | UK-6005-R4 |
| 6 | US-0120-R3 | US0120R3 | US-0120R3 | US-0120-R3 |
Enter B2:G2, then fill through row 6:
B2: =SUBSTITUTE(A2,"-","")
C2: =SUBSTITUTE(A2,"-","",2)
D2: =SUBSTITUTE(A2,"R1","R4")
E2: =LEN(A2)
F2: =LEN(B2)
G2: =E2-F2
E is 10, F is 8 and G is 2 throughout. C retains the first hyphen and has nine characters. D affects only rows 2 and 5. Keep the raw source: removing separators is a lossy transformation, even when the displayed compact code looks reasonable.
Compare all matches with one match
Create Occurrences, with four columns and nine rows. Enter these formulas in A2:A8, B2 =LEN(A2) filled through B8, and C2 =ISTEXT(A2) filled through C8.
| Row | Formula in A | Expected text | B: length |
|---|---|---|---|
| 2 | =SUBSTITUTE("red-red-red","red","blue") |
blue-blue-blue | 14 |
| 3 | =SUBSTITUTE("red-red-red","red","blue",2) |
red-blue-red | 12 |
| 4 | =SUBSTITUTE("red-red-red","red","blue",3) |
red-red-blue | 12 |
| 5 | =SUBSTITUTE("red-red-red","red","blue",4) |
red-red-red | 11 |
| 6 | =SUBSTITUTE("CA-2048","-","",2) |
CA-2048 | 7 |
| 7 | =SUBSTITUTE(60606,6,3) |
30303 | 5 |
| 8 | =SUBSTITUTE("catalog cat","cat","dog") |
dogalog dog | 11 |
All C results are TRUE. Apple explicitly allows replacements inside words, which is why the last formula changes the beginning of catalog too. It is not a whole-word matching rule.
Advanced: replacement order can change the answer
Create ReplacementOrder, with six columns and five rows. Put AB, AAB and BABA in A2:A4. Enter B2:F2 and fill through row 4:
B2: =SUBSTITUTE(A2,"A","B")
C2: =SUBSTITUTE(B2,"B","C")
D2: =SUBSTITUTE(A2,"B","C")
E2: =SUBSTITUTE(D2,"A","B")
F2: =EXACT(C2,E2)
| Source | B | C: A→B then B→C | D | E: B→C then A→B | F |
|---|---|---|---|---|---|
| AB | BB | CC | AC | BC | FALSE |
| AAB | BBB | CCC | AAC | BBC | FALSE |
| BABA | BBBB | CCCC | CACA | CBCB | FALSE |
The first pipeline creates additional Bs for its second step to change. The reverse pipeline does not revisit those newly created Bs. A nested expression such as =SUBSTITUTE(SUBSTITUTE(A2,"A","B"),"B","C") has the same order as B then C. Separate columns make that order visible before nesting.
On a separate Collisions table with four columns and four rows, put CA-20-48-R1 in A2 and CA-2048-R1 in A3. B2 =SUBSTITUTE(A2,"-","") filled through B3 gives CA2048R1 in both cells. C2 =EXACT(A2,A3) is FALSE; D2 =EXACT(B2,B3) is TRUE. A cleanup rule can merge distinct strings, so a matching cleaned value does not prove the raw identifiers were identical.
Excel comparison and boundaries
Microsoft’s current SUBSTITUTE reference also uses an optional fourth occurrence selector and replaces all matches when it is omitted. That supports the basic literal-substring comparison. It does not establish Numbers parity for Excel’s entire error or import behavior, or for Apple’s REGEX extension.
Apple does not spell out empty-search-string behavior, every fractional occurrence, overlap rule or exact invalid-argument error token in this entry. Keep those cases separate from the positive integer, nonempty searches above. EXACT compares the resulting strings, while LEN measures how much the transformation changed their length.
Formula entry and practical limits
Examples use commas between arguments, ordinary straight quotation marks around literals, one header row and no header columns. If your decimal separator is a comma, Numbers uses semicolons between arguments. Keep output columns separate from the original data, and select source cells in the formula editor if table-qualified references are needed.
The short function entry does not establish every imported type, error-propagation rule or exact error message. These explicit examples do not certify complex Unicode segmentation or cross-client workbook conversion. Diagnose a mismatch with a small original input before changing a whole column.