diff options
| author | Alberto Donizetti <alb.donizetti@gmail.com> | 2018-04-25 20:48:01 +0200 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-04-26 15:11:58 +0000 |
| commit | 2191c3a4b9b8738b3033fd271b8b889cb3149292 (patch) | |
| tree | efd866c54ed542b9f14815ad8f08913ce814692e /src/strings/replace.go | |
| parent | bf6530a25b07b6cbde4f1d7b25e549675340dec1 (diff) | |
| download | go-2191c3a4b9b8738b3033fd271b8b889cb3149292.tar.xz | |
strings: clarify Replacer's replacement order
NewReplacer's documentation says that "replacements are performed in
order", meaning that substrings are replaced in the order they appear
in the target string, and not that the old->new replacements are
applied in the order they're passed to NewReplacer.
Rephrase the doc to make this clearer.
Fixes #25071
Change-Id: Icf3aa6a9d459b94764c9d577e4a76ad8c04d158d
Reviewed-on: https://go-review.googlesource.com/109375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/strings/replace.go')
| -rw-r--r-- | src/strings/replace.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/strings/replace.go b/src/strings/replace.go index bb0524427b..58a11a63db 100644 --- a/src/strings/replace.go +++ b/src/strings/replace.go @@ -18,8 +18,9 @@ type replacer interface { WriteString(w io.Writer, s string) (n int, err error) } -// NewReplacer returns a new Replacer from a list of old, new string pairs. -// Replacements are performed in order, without overlapping matches. +// 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. func NewReplacer(oldnew ...string) *Replacer { if len(oldnew)%2 == 1 { panic("strings.NewReplacer: odd argument count") |
