|
|
@ -1,8 +1,6 @@
|
|
|
|
package stringx
|
|
|
|
package stringx
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import "strings"
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
type (
|
|
|
|
// Replacer interface wraps the Replace method.
|
|
|
|
// Replacer interface wraps the Replace method.
|
|
|
@ -32,7 +30,7 @@ func NewReplacer(mapping map[string]string) Replacer {
|
|
|
|
|
|
|
|
|
|
|
|
// Replace replaces text with given substitutes.
|
|
|
|
// Replace replaces text with given substitutes.
|
|
|
|
func (r *replacer) Replace(text string) string {
|
|
|
|
func (r *replacer) Replace(text string) string {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
var buf strings.Builder
|
|
|
|
target := []rune(text)
|
|
|
|
target := []rune(text)
|
|
|
|
cur := r.node
|
|
|
|
cur := r.node
|
|
|
|
nextStart := 0
|
|
|
|
nextStart := 0
|
|
|
|