strings.substring() function
The strings.substring()
function returns a substring based on start
and end
parameters.
These parameters are represent indices of UTF code points in the string.
Output data type: String
import "strings"
strings.substring(v: "influx", start: 0, end: 4)
// returns "infl"
Parameters
v
The string value to search.
Data type: String
start
The starting inclusive index of the substring.
Data type: Integer
end
The ending exclusive index of the substring.
Data type: Integer
Examples
Store the first four characters of a string
import "strings"
data
|> map(fn: (r) => ({
r with
abbr: strings.substring(v: r.name, start: 0, end: 4)
})
)
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.