diff options
author | Francisco Rojas <francisco.rojas.gallegos@gmail.com> | 2017-07-15 14:51:58 -0600 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-07-15 21:14:22 +0000 |
commit | b119ef154c1cc3bded16baff06143844bf1b28e1 (patch) | |
tree | fae4825edae3691cf8d837f600d227704e19ad66 | |
parent | bcc349aecf7bb26d4430e8f8ab60d9362181d1a0 (diff) | |
download | go-b119ef154c1cc3bded16baff06143844bf1b28e1.tar.gz go-b119ef154c1cc3bded16baff06143844bf1b28e1.zip |
strings: add a example for TrimFunc
Change-Id: I9c0c601ec5957475e949dcc4a8c2116724d01215
Reviewed-on: https://go-review.googlesource.com/48961
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r-- | src/strings/example_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/strings/example_test.go b/src/strings/example_test.go index 473b8c3833..e9621522ef 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -234,6 +234,14 @@ func ExampleTrim() { // 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() { rot13 := func(r rune) rune { switch { |