TrimFunc in Go

Posted by GoDoc
Public (Editable by Users)

TrimFunc returns a slice of the string s with all leading and trailing Unicode code points c satisfying f(c) removed.

Go
Edit
package main

import (
	"fmt"
	"strings"
	"unicode"
)

func main() {
	fmt.Print(strings.TrimFunc("¡¡¡Hello, Gophers!!!", func(r rune) bool {
		return !unicode.IsLetter(r) && !unicode.IsNumber(r)
	}))
}