Skip to content

strings: Replacer fails at beginning of string #6659

@robpike

Description

@robpike
package main

import(
    "fmt"
    "strings"
)

func main(){
    fmt.Println(strings.NewReplacer("Hello", "").Replace("Hellox"))
    fmt.Println(strings.NewReplacer("Hello", "").Replace("xHellox"))
}

Prints

Hellox
xx

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions