strings.FieldsFunc() Function in Golang With Examples
strings.FieldsFunc() Function in Golang is used to splits the given string str at each run of Unicode code points c satisfying f(c) and returns an array of slices of str.
Syntax:func FieldsFunc(str string, f func(rune) bool) string
Here, str is the given string, the rune is a built-in type meant to contain a single Unicode character and f is a user-defined function.
Return: If all code points in str satisfy f(c) or the string is empty, an empty slice is returned.
Note: This function makes no guarantees about the order in which it calls f(c). If f does not return consistent results for a given c, FieldsFunc may crash.
Fields are: ["ABC" "PQR" "XYZ"]
Fields are: ["We" "are" "humans" "We" "are" "social" "animals"]