← substr operator page · string/substr/ds_start_len/manual_ex_2
pandas ✅ · DuckDB ✅
substr(DS_1, 1, 5): the first five characters of every value of both measures.
Sub-string extraction, Example 2, output verbatim: "The substring starts from the startth character of the input string and has a number of characters equal to the length parameter."
Me_1 is hello, abcde and pqrst; Me_2 is mediu, short and "this " (with its trailing space).
DS_r:= substr ( DS_1 , 1 , 5 );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | hello world | medium size text |
| 1 | B | abcdefghilmno | short text |
| 2 | A | pqrstuvwxyz | this is a long description |
{
"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},
{"name": "Me_2", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | hello | mediu |
| 1 | B | abcde | short |
| 2 | A | pqrst | this |
{
"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"}
]
}
]
}