Standard library / strings

strings.TrimFunc()

Removes leading and trailing runes satisfying f. Expected stdout: 'go\n'.

Formal Syntax & Structure

go syntaxgo
func TrimFunc(s string, f func(rune) bool) string

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
ffunc(rune) boolPredicate over decoded runes.

Return Value

string

Removes leading and trailing runes satisfying f.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings"  "unicode")
func main() {  fmt.Println(string(strings.TrimFunc("12go34", unicode.IsDigit)))}
Go Reference