{
  "$schema": "/products/haybarn/functions/api/v1/function.schema.json",
  "schemaVersion": 1,
  "name": "regexp_replace",
  "schema": "main",
  "slug": "regexp_replace",
  "description": "If `string` contains the regexp `pattern`, replaces the matching part with `replacement`. A set of optional `options` can be set.",
  "category": "text",
  "kinds": [
    "scalar"
  ],
  "aliasOf": [],
  "snapshot": {
    "schemaVersion": 1,
    "id": "duckdb-1.3.2",
    "engine": "duckdb",
    "label": "DuckDB 1.3.2",
    "engineVersion": "v1.3.2",
    "sourceId": "0b83e5d2f6",
    "source": "https://github.com/duckdb/duckdb/releases/tag/v1.3.2",
    "binarySha256": "9a2ae2a4d5dbd07a5b0cb30c502d65014825d34924c681eb3faa7647e7cd2b6f",
    "capturedAt": "2026-09-05T18:37:33.818Z",
    "requestedExtensions": [
      "core_functions",
      "icu",
      "json",
      "parquet"
    ],
    "loadedExtensions": [
      {
        "extension_name": "autocomplete",
        "extension_version": "v1.3.2",
        "installed_from": ""
      },
      {
        "extension_name": "core_functions",
        "extension_version": "v1.3.2",
        "installed_from": ""
      },
      {
        "extension_name": "icu",
        "extension_version": "v1.3.2",
        "installed_from": ""
      },
      {
        "extension_name": "json",
        "extension_version": "v1.3.2",
        "installed_from": ""
      },
      {
        "extension_name": "parquet",
        "extension_version": "v1.3.2",
        "installed_from": ""
      },
      {
        "extension_name": "shell",
        "extension_version": "v1.3.2",
        "installed_from": ""
      }
    ],
    "scope": "Built-in functions in the main schema, with the requested extensions loaded. Catalog visibility is not a guarantee of browser support."
  },
  "links": {
    "html": "/products/haybarn/functions/releases/duckdb-1.3.2/regexp_replace/",
    "markdown": "/products/haybarn/functions/releases/duckdb-1.3.2/regexp_replace/index.md",
    "json": "/products/haybarn/functions/api/v1/duckdb-1.3.2/functions/regexp_replace.json"
  },
  "interpretation": [
    "Choose a snapshot matching the target engine and build. The default is captured from the published Haybarn WASM package used by the browser playground. Historical native snapshots are also available.",
    "Availability is an observation in the recorded build and extension profile, not a guarantee of support in every installation or in WASM.",
    "Types and descriptions are declarations from duckdb_functions(). Binding can specialize result types. Null means not supplied by the catalog; do not invent defaults, optionality, argument mode, or table output columns.",
    "Raw parameter arrays preserve catalog order for scalar/aggregate/macro functions. Raw table arguments are alphabetical. Use callingConvention for engine-confirmed positional order and named arguments; null modes are unrecorded. Named does not mean optional. Macro defaults and special named variadic behavior are not supplied by duckdb_functions().",
    "Catalog examples are source material and may require data or extensions. runnableExamples contains separately verified SQL for the pinned WASM package; sample-data adaptations and guide examples are labeled separately.",
    "Guide annotations and recipes are separate editorial content. The browser runner always uses Haybarn WASM 1.5.5-rc3, independently of the documentation snapshot.",
    "All URLs beginning with / are relative to the origin hosting this document. Exports require no JavaScript, cookies, API key, or browser engine."
  ],
  "overloads": [
    {
      "id": "overload-e9557df4080fe3ad",
      "url": "/products/haybarn/functions/releases/duckdb-1.3.2/regexp_replace/#overload-e9557df4080fe3ad",
      "signature": "regexp_replace(string: VARCHAR, pattern: VARCHAR, replacement[: VARCHAR) → VARCHAR",
      "parameterOrder": "catalog-order",
      "callingConvention": {
        "source": null,
        "parameters": [
          {
            "name": "string",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          },
          {
            "name": "pattern",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          },
          {
            "name": "replacement[",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          }
        ],
        "positional": null,
        "named": null,
        "variadic": null,
        "evidence": null
      },
      "syntax": {
        "kind": "function",
        "operator": null
      },
      "catalog": {
        "schema_name": "main",
        "function_name": "regexp_replace",
        "function_type": "scalar",
        "description": "If `string` contains the regexp `pattern`, replaces the matching part with `replacement`. A set of optional `options` can be set.",
        "comment": null,
        "return_type": "VARCHAR",
        "parameters": [
          "string",
          "pattern",
          "replacement["
        ],
        "parameter_types": [
          "VARCHAR",
          "VARCHAR",
          "VARCHAR"
        ],
        "varargs": null,
        "macro_definition": null,
        "has_side_effects": false,
        "internal": true,
        "examples": [
          "regexp_replace('hello', '[lo]', '-')"
        ],
        "stability": "CONSISTENT",
        "categories": [],
        "alias_of": null
      }
    },
    {
      "id": "overload-452cae60e345036b",
      "url": "/products/haybarn/functions/releases/duckdb-1.3.2/regexp_replace/#overload-452cae60e345036b",
      "signature": "regexp_replace(string: VARCHAR, pattern: VARCHAR, replacement[: VARCHAR, options]: VARCHAR) → VARCHAR",
      "parameterOrder": "catalog-order",
      "callingConvention": {
        "source": null,
        "parameters": [
          {
            "name": "string",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          },
          {
            "name": "pattern",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          },
          {
            "name": "replacement[",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          },
          {
            "name": "options]",
            "type": "VARCHAR",
            "mode": null,
            "position": null
          }
        ],
        "positional": null,
        "named": null,
        "variadic": null,
        "evidence": null
      },
      "syntax": {
        "kind": "function",
        "operator": null
      },
      "catalog": {
        "schema_name": "main",
        "function_name": "regexp_replace",
        "function_type": "scalar",
        "description": "If `string` contains the regexp `pattern`, replaces the matching part with `replacement`. A set of optional `options` can be set.",
        "comment": null,
        "return_type": "VARCHAR",
        "parameters": [
          "string",
          "pattern",
          "replacement[",
          "options]"
        ],
        "parameter_types": [
          "VARCHAR",
          "VARCHAR",
          "VARCHAR",
          "VARCHAR"
        ],
        "varargs": null,
        "macro_definition": null,
        "has_side_effects": false,
        "internal": true,
        "examples": [
          "regexp_replace('hello', '[lo]', '-')"
        ],
        "stability": "CONSISTENT",
        "categories": [],
        "alias_of": null
      }
    }
  ],
  "editorial": {
    "argumentNotes": [],
    "recipes": [
      {
        "id": "clean-text",
        "title": "Turn a label into a useful key.",
        "description": "Trim the edges, normalize case, and replace runs of spaces. Small functions compose into a readable cleaning step.",
        "sql": "SELECT regexp_replace(\n  lower(trim('  Summer Harvest 2026  ')),\n  '\\s+', '-', 'g'\n) AS slug;",
        "source": "guide-recipe",
        "verification": null,
        "intendedRuntime": {
          "engine": "haybarn-wasm",
          "packageVersion": "1.5.5-rc3"
        }
      }
    ]
  },
  "examples": [
    {
      "original": "regexp_replace('hello', '[lo]', '-')",
      "sql": "SELECT regexp_replace('hello', '[lo]', '-');",
      "overloadIds": [
        "overload-e9557df4080fe3ad",
        "overload-452cae60e345036b"
      ],
      "source": "engine-catalog",
      "verification": null
    }
  ],
  "translations": [
    {
      "function": "regexp_replace",
      "scope": "",
      "relation": "direct",
      "source": {
        "engine": "PostgreSQL",
        "dialect": "postgres",
        "name": "regexp_replace",
        "names": [
          "regexp_replace"
        ],
        "sql": "SELECT REGEXP_REPLACE('aaa', 'a', 'b')"
      },
      "target": {
        "dialect": "duckdb",
        "name": "regexp_replace",
        "sql": "SELECT REGEXP_REPLACE('aaa', 'a', 'b')"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_postgres.py#L1152"
      }
    },
    {
      "function": "regexp_replace",
      "scope": "",
      "relation": "direct",
      "source": {
        "engine": "Exasol",
        "dialect": "exasol",
        "name": "regexp_replace",
        "names": [
          "regexp_replace"
        ],
        "sql": "REGEXP_REPLACE(subject, pattern, replacement, position, occurrence)"
      },
      "target": {
        "dialect": "duckdb",
        "name": "regexp_replace",
        "sql": "REGEXP_REPLACE(subject, pattern, replacement)"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_exasol.py#L373"
      }
    },
    {
      "function": "regexp_replace",
      "scope": "",
      "relation": "direct",
      "source": {
        "engine": "Snowflake",
        "dialect": "snowflake",
        "name": "regexp_replace",
        "names": [
          "regexp_replace"
        ],
        "sql": "REGEXP_REPLACE(subject, pattern)"
      },
      "target": {
        "dialect": "duckdb",
        "name": "regexp_replace",
        "sql": "REGEXP_REPLACE(subject, pattern, '', 'g')"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_snowflake.py#L5169"
      }
    }
  ],
  "runnableExamples": [
    {
      "function": "regexp_replace",
      "original": "regexp_replace('hello', '[lo]', '-')",
      "sql": "SELECT regexp_replace('hello', '[lo]', '-');",
      "source": "engine-catalog",
      "verification": {
        "engine": "haybarn-wasm",
        "packageVersion": "1.5.5-rc3",
        "sourceId": "105edd31b5",
        "binarySha256": "426638bc374fcc542fea93b251f885bfb7d221c68fcc0a5a81cc565d7e6ca180",
        "rowCount": 1
      }
    }
  ],
  "additionalDocumentation": [
    {
      "title": "Regular Expressions",
      "url": "https://duckdb.org/docs/current/sql/functions/regular_expressions#regexp_replacestring-pattern-replacement-options"
    },
    {
      "title": "Text Functions",
      "url": "https://duckdb.org/docs/current/sql/functions/text#regexp_replacestring-regex-replacement-options"
    },
    {
      "title": "Text Functions",
      "url": "https://duckdb.org/docs/current/sql/functions/text.html#regexp_replacestring-regex-replacement-options"
    }
  ],
  "availability": [
    {
      "snapshot": "haybarn-1.5.5-rc3",
      "observed": true,
      "overloadCount": 2,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/haybarn-1.5.5-rc3/functions/regexp_replace.json"
    },
    {
      "snapshot": "duckdb-1.5.5",
      "observed": true,
      "overloadCount": 2,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.5.5/functions/regexp_replace.json"
    },
    {
      "snapshot": "duckdb-1.4.4",
      "observed": true,
      "overloadCount": 2,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.4.4/functions/regexp_replace.json"
    },
    {
      "snapshot": "duckdb-1.3.2",
      "observed": true,
      "overloadCount": 2,
      "matchingOverloadIds": [
        "overload-452cae60e345036b",
        "overload-e9557df4080fe3ad"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.3.2/functions/regexp_replace.json"
    }
  ]
}
