Commit b119ef15 authored by Francisco Rojas's avatar Francisco Rojas Committed by Brad Fitzpatrick

strings: add a example for TrimFunc

Change-Id: I9c0c601ec5957475e949dcc4a8c2116724d01215
Reviewed-on: https://go-review.googlesource.com/48961Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
parent bcc349ae
...@@ -234,6 +234,14 @@ func ExampleTrim() { ...@@ -234,6 +234,14 @@ func ExampleTrim() {
// Output: ["Achtung! Achtung"] // Output: ["Achtung! Achtung"]
} }
func ExampleTrimFunc() {
f := func(c rune) bool {
return !unicode.IsLetter(c) && !unicode.IsNumber(c)
}
fmt.Printf("[%q]", strings.TrimFunc(" Achtung1! Achtung2,...", f))
// Output: ["Achtung1! Achtung2"]
}
func ExampleMap() { func ExampleMap() {
rot13 := func(r rune) rune { rot13 := func(r rune) rune {
switch { switch {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment