]> Cypherpunks repositories - gostls13.git/commitdiff
strings: add ReplaceAll example
authordupoxy <dupoxy@users.noreply.github.com>
Wed, 12 Dec 2018 22:49:31 +0000 (22:49 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 13 Dec 2018 00:35:06 +0000 (00:35 +0000)
Change-Id: I6b0d470bdedb92844943c8e5823e214d6a7471cf
GitHub-Last-Rev: 4a135000ba9c23a588b960e5b2989710cc71e3e2
GitHub-Pull-Request: golang/go#29199
Reviewed-on: https://go-review.googlesource.com/c/153840
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/strings/example_test.go

index 607e4a0a70e7afdcc6bff41a723f6ca966e28e3a..e31054a4e0b31355e51ed3d2f904d785bc688503 100644 (file)
@@ -205,6 +205,12 @@ func ExampleReplace() {
        // moo moo moo
 }
 
+func ExampleReplaceAll() {
+       fmt.Println(strings.ReplaceAll("oink oink oink", "oink", "moo"))
+       // Output:
+       // moo moo moo
+}
+
 func ExampleSplit() {
        fmt.Printf("%q\n", strings.Split("a,b,c", ","))
        fmt.Printf("%q\n", strings.Split("a man a plan a canal panama", "a "))