go/src/strings/replace.go

type Replacer

type replacer

// 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. The old string
// comparisons are done in argument order.
//
// NewReplacer panics if given an odd number of arguments.
func NewReplacer(oldnew ...string) *Replacer {}

func (r *Replacer) buildOnce() {}

func (b *Replacer) build() replacer {}

// Replace returns a copy of s with all replacements performed.
func (r *Replacer) Replace(s string) string {}

// WriteString writes s to w with all replacements performed.
func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error) {}

type trieNode

func (t *trieNode) add(key, val string, priority int, r *genericReplacer) {}

func (r *genericReplacer) lookup(s string, ignoreRoot bool) (val string, keylen int, found bool) {}

type genericReplacer

func makeGenericReplacer(oldnew []string) *genericReplacer {}

type appendSliceWriter

// Write writes to the buffer to satisfy [io.Writer].
func (w *appendSliceWriter) Write(p []byte) (int, error) {}

// WriteString writes to the buffer without string->[]byte->string allocations.
func (w *appendSliceWriter) WriteString(s string) (int, error) {}

type stringWriter

func (w stringWriter) WriteString(s string) (int, error) {}

func getStringWriter(w io.Writer) io.StringWriter {}

func (r *genericReplacer) Replace(s string) string {}

func (r *genericReplacer) WriteString(w io.Writer, s string) (n int, err error) {}

type singleStringReplacer

func makeSingleStringReplacer(pattern string, value string) *singleStringReplacer {}

func (r *singleStringReplacer) Replace(s string) string {}

func (r *singleStringReplacer) WriteString(w io.Writer, s string) (n int, err error) {}

type byteReplacer

func (r *byteReplacer) Replace(s string) string {}

func (r *byteReplacer) WriteString(w io.Writer, s string) (n int, err error) {}

type byteStringReplacer

const countCutOff

func (r *byteStringReplacer) Replace(s string) string {}

func (r *byteStringReplacer) WriteString(w io.Writer, s string) (n int, err error) {}