← instr operator page · string/instr/ds_pattern/manual_ex_1
pandas ✅ · DuckDB ✅
instr(DS_1, "hello") on a dataset with one String measure: the position of hello in each value.
String pattern location, Example 1, output verbatim: "The operator returns the position in the input string of a specified string ( pattern )." For a data set, "instr returns a dataset with a single measure int_var of type integer."
int_var is 1 for hello world, 5 for say hello and for "hi, hello! ", and 0 for he, where hello is not found and "the returned value is 0".
DS_r:= instr(DS_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 | int_var |
|---|---|---|
| 1 | A | 1 |
| 2 | A | 5 |
| 3 | A | 0 |
| 4 | A | 5 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "int_var", "type": "Integer", "role": "Measure"}
]
}
]
}