1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-24 06:09:01 +08:00
nali/internal/tools/replace.go

13 lines
311 B
Go
Raw Normal View History

2020-07-21 17:23:38 +08:00
package tools
import "strings"
func ReplaceAdd(origin string, old string, new string) string {
subLen := len(new) - len(old)
wanted := old + strings.Repeat(" ", subLen)
if strings.Contains(origin, wanted) {
return strings.ReplaceAll(origin, wanted, new)
}
return strings.ReplaceAll(origin, old, new)
}