Shape / columns · All operations

Find and replace text inside values

A variant of Replace values

Replace a substring or pattern wherever it occurs inside a text value.

Status

In arcform

Runs as a SQL step

arcform carries it as a sql: step today.

The DuckDB step

Replace a substring wherever it occurs inside a value

It reads the orders table the proofs share. Create it first:

SQL
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);

Then run the statement:

SQL
CREATE TEMP TABLE result AS
SELECT order_id, customer, replace(customer, '  ', ' ') AS customer_clean, product, replace(product, 'get', 'GET') AS product_marked FROM orders;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT customer_clean FROM result WHERE order_id = 3) = 'Bob Okafor' AND (SELECT count(*) FROM result WHERE customer_clean <> customer) = 1 AND (SELECT list(DISTINCT product_marked ORDER BY product_marked) FROM result) = ['gadGET', 'gizmo', 'widGET']) THEN 'as expected' ELSE error('the double space was not collapsed in one name, or get was not replaced inside widget and gadget') END AS verdict;
  • It needs nothing installed beyond DuckDB itself.
  • The statement checks its own result and raises an error when it is wrong: “the double space was not collapsed in one name, or get was not replaced inside widget and gadget”.
  • It passed on DuckDB v2.0.0 (Cyanoptera) d54cbbe3df.

What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

Apache Hop (2)
  • Replace in Stringread 2026-09-27

    Search and replace text in string fields, by literal or regular expression

  • Token replacementread 2026-09-27

    Replace named tokens in a template string or file with values from fields

Apache SeaTunnel (1)
  • Replaceread 2026-09-27

    Replace substrings of a field that match a literal or a regex

Duckle (1)
Ibis (1)
  • StringReplaceread 2026-09-27

    Replace a literal substring in a string with another string

KNIME Analytics Platform (1)
  • String Replacerread 2026-09-27

    Replace strings in a column that match a wildcard or regex pattern

OpenRefine (1)
  • Replace…read 2026-09-27

    Find and replace text in a column, with case, whole-word and regular-expression options

Pentaho Data Integration (1)
  • Replace in Stringread 2026-09-27

    Replace every occurrence of a word in a string with another

Power Query M (1)
  • Replacer functionsread 2026-09-27

    2 functions used by replace operations: Replacer.ReplaceText, Replacer.ReplaceValue

Trifacta (5)

Background

A string replace function returns a string with occurrences of a find string changed to a replacement string.[1] In PostgreSQL, replace changes all occurrences of a substring, so replace('abcdefabcdef', 'cd', 'XX') returns abXXefabXXef.[2] In Python, str.replace replaces every occurrence of a substring unless a count is given, and then only the first count occurrences.[3]

When to use it

In OpenRefine, find and replace can be set to select whole words only, so that searching for house does not select the house part of doghouse.[4] In OpenRefine, the cells a find and replace will change can be previewed first by testing the search with a text filter.[4] In Apache Hop, the Replace in String transform has a whole-word option and a case-sensitivity option.[5] Before replacing a short string across a column, look at the values that contain it inside a longer word. (Meridian's view)

In pandas, Series.str.replace treats its pattern as a literal string by default, and as a regular expression only when regex is True.[6] In pandas, replacing f. with ba literally leaves fuz unchanged, while the same pattern as a regular expression turns fuz into baz.[6] Use a literal replace unless the search really is a pattern. (Meridian's view)

In pandas, Series.str.replace is case sensitive by default when its pattern is a string, and is made case insensitive by setting case to False.[6]

The method

In DuckDB, replace(string, source, target) replaces any occurrences of source with target in string.[7] In PostgreSQL, overlay replaces the substring that starts at a given character and extends for a given count of characters with a new substring.[2]

Compared with the alternatives

In DuckDB, translate('12345', '143', 'ax') returns a2x5.[7] Reach for translate to swap or strip single characters, and for replace when what changes is a word or a run of characters. (Meridian's view)