← replace operator page · string/replace/comp_two/manual_ex_2
pandas ✅ · DuckDB ✅
replace(Me_1, "ello", "i") inside calc, where the new measure Me_2 takes the result.
String pattern replacement, Example 2, output verbatim: "Replaces all the occurrences of a specified string-pattern (pattern1) with another one (pattern2)."
Me_2 is hi world, say hi, he and hi!; Me_1 is kept.
DS_r := DS_1[ calc Me_2:= replace (Me_1,"ello","i")];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | hello world |
| 2 | A | say hello |
| 3 | A | he |
| 4 | A | hello! |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | hello world | hi world |
| 2 | A | say hello | say hi |
| 3 | A | he | he |
| 4 | A | hello! | hi! |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"}
]
}
]
}