Skip to content

regsub

Written as regsub(argnum flags):options in a transform expression.

Minimum arguments 1
Maximum arguments 1
Default arguments 1
Argument modes SINGLE_PRIMITIVE

Perform regex substitutions on text with sed-like syntax.

Features:

  • Supports sed-style substitution syntax with custom separators
  • Case-insensitive matching with ‘i’ flag
  • Global replacement with ‘g’ flag
  • Automatically handles None values (returns None if input is None)

Syntax: “regsub:{sep}{pattern}{sep}{replacement}{sep}{flags}” Where:

  • {sep} is any single character delimiter (commonly / or #)
  • {pattern} is the regex pattern to match
  • {replacement} is the replacement text
  • {flags} optional flags (combinations of ‘i’ and ‘g’)

Flags:

  • ‘i’: Case-insensitive matching
  • ‘g’: Replace all occurrences (global) instead of just first

Note: The separator character must not appear in the pattern or replacement unless escaped. For complex patterns, choose a separator that doesn’t conflict with your regex syntax.

Flag Letter
noncaptive_input I
Input args: ["Hello world"]
Transforms: "regsub:/world/planet/"
Output: "Hello planet"
Input args: ["Foo foo FOO"]
Transforms: "regsub:#foo#bar#gi"
Output: "bar bar bar"
Input args: ["price=100"]
Transforms: "regsub:|price=(\\d+)|cost:\\1|"
Output: "cost:100"
Input args: ["a a a a"]
Transforms: "regsub:/a/b/"
Output: "b a a a"
Input args: ["2023-01-15"]
Transforms: "regsub:#(\\d{4})-(\\d{2})-(\\d{2})#\\3/\\2/\\1#"
Output: "15/01/2023"