strings: Add FieldsFunc example.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/42360043
diff --git a/src/pkg/strings/example_test.go b/src/pkg/strings/example_test.go
index 36e0a42..ccfc417 100644
--- a/src/pkg/strings/example_test.go
+++ b/src/pkg/strings/example_test.go
@@ -7,6 +7,7 @@
import (
"fmt"
"strings"
+ "unicode"
)
func ExampleFields() {
@@ -14,6 +15,14 @@
// Output: Fields are: ["foo" "bar" "baz"]
}
+func ExampleFieldsFunc() {
+ f := func(c rune) bool {
+ return !unicode.IsLetter(c) && !unicode.IsNumber(c)
+ }
+ fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f))
+ // Output: Fields are: ["foo1" "bar2" "baz3"]
+}
+
func ExampleContains() {
fmt.Println(strings.Contains("seafood", "foo"))
fmt.Println(strings.Contains("seafood", "bar"))