TrimRightFunc in Go

Posted by GoDoc
Public (Editable by Users)

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

Go
Edit
package main

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

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