Skip to content

strings, bytes: Document behavior of Replace when old is empty #8143

Description

@cespare
strings.Replace and bytes.Replace insert 'new' in between each rune when 'old' is empty:

strings.Replace("foo 世界", "", ".", -1) // .f.o.o.
.世.界.

Especially for package bytes, this behavior is a little surprising (one might expect new
to be inserted between each byte). It can't be changed, but it should at least be
documented.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions