← replace operator page · string/replace/ds_one/replacement_omitted

Replacement omitted 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

replace(DS_1, "l") with pattern2 omitted.

Manual:

String pattern replacement: "If pattern2 is omitted then all occurrences of pattern1 are removed."

Expected:

hello world, which has three l, gives heo word; say has none and is kept. A null operand gives a null result: "most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null" (User Manual), as the manual's length and instr examples show.

script.vtl ⇩

DS_r := replace(DS_1, "l");

input/DS_1.csv ⇩

Id_1Me_1
1hello world
2say
3

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1
1heo word
2say
3

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "String", "role": "Measure"}
      ]
    }
  ]
}