diff options
author | Francesco Renzi <rentziass@gmail.com> | 2019-07-09 14:43:10 +0100 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2019-07-10 21:26:21 +0000 |
commit | 80cca23b59fe75ba588f7ddee7adb48a6afe2eb7 (patch) | |
tree | a3ad8ebe00f9376e21b2429dc0421a886ea7d82e /src/strings | |
parent | 9d56dd8ea30068aa3b3211939b50407b10edb50e (diff) | |
download | go-80cca23b59fe75ba588f7ddee7adb48a6afe2eb7.tar.gz go-80cca23b59fe75ba588f7ddee7adb48a6afe2eb7.zip |
strings: document that order of pairs matters in NewReplacer
Update NewReplacer documentation to specify that in the case of
multiple matches at the same position, the matching old/new
pair that appears first in NewReplacer arguments takes precedence.
Fixes #32699
Change-Id: I9d0616d28e5cd8c9bfa301be201f2b0ebf361dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/185099
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/strings')
-rw-r--r-- | src/strings/replace.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/strings/replace.go b/src/strings/replace.go index ccab1fb861..e28d428879 100644 --- a/src/strings/replace.go +++ b/src/strings/replace.go @@ -25,7 +25,8 @@ type replacer interface { // NewReplacer returns a new Replacer from a list of old, new string // pairs. Replacements are performed in the order they appear in the -// target string, without overlapping matches. +// target string, without overlapping matches. The old string +// comparisons are done in argument order. // // NewReplacer panics if given an odd number of arguments. func NewReplacer(oldnew ...string) *Replacer { |