content/flux/v0/stdlib/strings/strlen.md
strings.strlen() returns the length of a string. String length is determined by the number of UTF code points a string contains.
(v: string) => int
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
({{< req >}}) String value to measure.
import "strings"
data
|> filter(fn: (r) => strings.strlen(v: r._value) <= 6)
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
| _time | _value | *tag |
|---|---|---|
| 2021-01-01T00:00:00Z | pl_gqcz | t1 |
| 2021-01-01T00:00:10Z | pl_gvn | t1 |
| 2021-01-01T00:00:20Z | pl_phw | t1 |
| 2021-01-01T00:00:30Z | pl_guvzy | t1 |
| 2021-01-01T00:00:40Z | pl_vcce | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | t1 |
| _time | _value | *tag |
|---|---|---|
| 2021-01-01T00:00:00Z | pl_beida | t2 |
| 2021-01-01T00:00:10Z | pl_euoxp | t2 |
| 2021-01-01T00:00:20Z | pl_gtz | t2 |
| 2021-01-01T00:00:30Z | pl_oxut | t2 |
| 2021-01-01T00:00:40Z | pl_wf | t2 |
| 2021-01-01T00:00:50Z | pl_dtnbv | t2 |
| _time | _value | *tag |
|---|---|---|
| 2021-01-01T00:00:10Z | pl_gvn | t1 |
| 2021-01-01T00:00:20Z | pl_phw | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | t1 |
| _time | _value | *tag |
|---|---|---|
| 2021-01-01T00:00:20Z | pl_gtz | t2 |
| 2021-01-01T00:00:40Z | pl_wf | t2 |
{{% /expand %}} {{< /expand-wrapper >}}
import "strings"
data
|> map(fn: (r) => ({r with length: strings.strlen(v: r._value)}))
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
| _time | _value | *tag |
|---|---|---|
| 2021-01-01T00:00:00Z | pl_gqcz | t1 |
| 2021-01-01T00:00:10Z | pl_gvn | t1 |
| 2021-01-01T00:00:20Z | pl_phw | t1 |
| 2021-01-01T00:00:30Z | pl_guvzy | t1 |
| 2021-01-01T00:00:40Z | pl_vcce | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | t1 |
| _time | _value | *tag |
|---|---|---|
| 2021-01-01T00:00:00Z | pl_beida | t2 |
| 2021-01-01T00:00:10Z | pl_euoxp | t2 |
| 2021-01-01T00:00:20Z | pl_gtz | t2 |
| 2021-01-01T00:00:30Z | pl_oxut | t2 |
| 2021-01-01T00:00:40Z | pl_wf | t2 |
| 2021-01-01T00:00:50Z | pl_dtnbv | t2 |
| _time | _value | length | *tag |
|---|---|---|---|
| 2021-01-01T00:00:00Z | pl_gqcz | 7 | t1 |
| 2021-01-01T00:00:10Z | pl_gvn | 6 | t1 |
| 2021-01-01T00:00:20Z | pl_phw | 6 | t1 |
| 2021-01-01T00:00:30Z | pl_guvzy | 8 | t1 |
| 2021-01-01T00:00:40Z | pl_vcce | 7 | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | 6 | t1 |
| _time | _value | length | *tag |
|---|---|---|---|
| 2021-01-01T00:00:00Z | pl_beida | 8 | t2 |
| 2021-01-01T00:00:10Z | pl_euoxp | 8 | t2 |
| 2021-01-01T00:00:20Z | pl_gtz | 6 | t2 |
| 2021-01-01T00:00:30Z | pl_oxut | 7 | t2 |
| 2021-01-01T00:00:40Z | pl_wf | 5 | t2 |
| 2021-01-01T00:00:50Z | pl_dtnbv | 8 | t2 |
{{% /expand %}} {{< /expand-wrapper >}}