Back to Influxdb

strings.isDigit() function

content/flux/v0/stdlib/strings/isdigit.md

latest2.3 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/strings/strings.flux#L516-L516 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

strings.isDigit() tests if a single-character string is a digit (0-9).

Function type signature
js
(v: string) => bool

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

v

({{< req >}}) Single-character string to test.

Examples

Filter by columns with digits as values

js
import "strings"

data
    |> filter(fn: (r) => strings.isDigit(v: r._value))

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_value*tag
2021-01-01T00:00:00Zst1
2021-01-01T00:00:10Znt1
2021-01-01T00:00:20Z4t1
2021-01-01T00:00:30Z4t1
2021-01-01T00:00:40Zet1
2021-01-01T00:00:50Zyt1
_time_value*tag
2021-01-01T00:00:00Zat2
2021-01-01T00:00:10Zpt2
2021-01-01T00:00:20Z4t2
2021-01-01T00:00:30Ztt2
2021-01-01T00:00:40Z7t2
2021-01-01T00:00:50Zvt2

Output data

_time_value*tag
2021-01-01T00:00:20Z4t1
2021-01-01T00:00:30Z4t1
_time_value*tag
2021-01-01T00:00:20Z4t2
2021-01-01T00:00:40Z7t2

{{% /expand %}} {{< /expand-wrapper >}}