mirror of
https://github.com/zu1k/nali.git
synced 2025-01-23 21:59:02 +08:00
16 lines
370 B
Go
16 lines
370 B
Go
package tools
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
func ReplaceAdd(origin string, old string, new string) (result string) {
|
|
subLen := len(new) - len(old)
|
|
wanted := old + strings.Repeat(" ", subLen)
|
|
if strings.Contains(origin, wanted) {
|
|
result = strings.ReplaceAll(origin, wanted, new)
|
|
}
|
|
result = strings.ReplaceAll(origin, old, new)
|
|
return strings.TrimRight(result, " \t")
|
|
}
|