replaceright

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package replaceright provides similar functionality to some of the standard library string replacement routines except they start from the right. Uses Boyer-Moore on longer strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Replace

func Replace(s, old, new string, n int) string

Similar to strings.Replace except it starts from the right, immediately returns if s or old is the empty string, and n cannot be < 0 as there's no reason to replace from the right if you're going to replace everything.

Types

type Replacer

type Replacer struct {
	// contains filtered or unexported fields
}

func NewReplacer

func NewReplacer(old, new string) *Replacer

Creates a new Replacer that can be used to repeatedly replace a single old-new pair. This implementation of Boyer-Moore is largely copied from the Go standard library.

func (*Replacer) Replace

func (rep *Replacer) Replace(s string, n int) string

Performs up to n replacements starting from the right.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL