mirror of
https://github.com/zu1k/nali.git
synced 2025-01-24 06:09:01 +08:00
13 lines
311 B
Go
13 lines
311 B
Go
|
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)
|
||
|
}
|