Skip to content

pgstrtranslate

Adds multi-character string replacement and text-array element removal functions.

pgstrtranslate · Adds multi-character string replacement and text-array element removal functions.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100690pgstrtranslatepgstrtranslate1.0FUNCUnknownC

Usage

Sources:

pgstrtranslate extends PostgreSQL’s character-wise translate operation with ordered multi-character replacements. Its function pgstrtranslate(boolean, text, text[], text[]) returns text.

CREATE EXTENSION pgstrtranslate;
SELECT pgstrtranslate(
  false,
  'abcdefghijkl',
  ARRAY['ab', 'efg', '2cd'],
  ARRAY['012', '3', '78']
);

With the first argument false, all search terms are matched against the original input, so replacements do not create new matches. With it true, replacements run sequentially and later search terms can match text produced by earlier replacements. Order therefore changes results.

Require search and replacement arrays to have the intended pairing and test empty elements, duplicates, overlaps, nulls, multibyte text, and expansion. The function is marked immutable, so any persisted index or generated value assumes stable byte-for-byte semantics. Version 1.0 has no current compatibility matrix; benchmark worst-case overlapping patterns and validate output before using it for canonicalization, security filtering, or identifiers.

Table reader