← instr operator page · string/instr/comp_pattern/manual_ex_2
pandas ✅ · DuckDB ✅
instr(Me_1, "hello") inside calc, where the new measure Me_2 takes the position.
String pattern location, Example 2, output verbatim: "The operator returns the position in the input string of a specified string ( pattern )."
Me_2 is 1, 5, 0 and 5; Me_1 is kept.
DS_r := DS_1[calc Me_2:=instr(Me_1,"hello")];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | hello world |
| 2 | A | say hello |
| 3 | A | he |
| 4 | A | hi, 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 | 1 |
| 2 | A | say hello | 5 |
| 3 | A | he | 0 |
| 4 | A | hi, hello! | 5 |
{
"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": "Integer", "role": "Measure"}
]
}
]
}