← replace operator page · string/replace/comp_patterns/patterns_from_components
pandas ✅ · DuckDB ✅
replace(Me_1, Me_2, Me_3) inside calc: both patterns come from components, a different pair for each data point.
String pattern replacement types pattern1 and pattern2 as component<string> | string, and "Replaces all the occurrences of a specified string-pattern (pattern1) with another one (pattern2)."
Me_4 is hello VTL, bANANa and abc: both an of banana are replaced, and x does not occur in abc. 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.
DS_r := DS_1[calc Me_4 := replace(Me_1, Me_2, Me_3)];
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | hello world | world | VTL |
| 2 | banana | an | AN |
| 3 | abc | x | y |
| 4 | a | b |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true},
{"name": "Me_2", "type": "String", "role": "Measure", "nullable": true},
{"name": "Me_3", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 | Me_3 | Me_4 |
|---|---|---|---|---|
| 1 | hello world | world | VTL | hello VTL |
| 2 | banana | an | AN | bANANa |
| 3 | abc | x | y | abc |
| 4 | a | b |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"},
{"name": "Me_3", "type": "String", "role": "Measure"},
{"name": "Me_4", "type": "String", "role": "Measure"}
]
}
]
}