Skip to content

proposal: strings,bytes: add ReplaceOnce #75554

@cuiweixie

Description

@cuiweixie

Proposal Details

as there many usage of Replace(old, new, 1).
I Proposal to add ReplaceOnce to strings and bytes package. Like wise ReplaceAll.

func ReplaceOnce(s, old, new string) string {
	return Replace(s, old, new, 1)
}
func ReplaceOnce(s, old, new []byte) []byte {
	return Replace(s, old, new, 1)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions