mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-07 22:22:29 +08:00
feat: add ReplaceWithMap
This commit is contained in:
@@ -446,10 +446,10 @@ func IndexOffset(str string, substr string, idxFrom int) int {
|
||||
return strings.Index(str[idxFrom:], substr) + idxFrom
|
||||
}
|
||||
|
||||
// ReplaceByMap returns a copy of `origin`,
|
||||
// ReplaceWithMap returns a copy of `str`,
|
||||
// which is replaced by a map in unordered way, case-sensitively.
|
||||
// Play: todo
|
||||
func ReplaceByMap(str string, replaces map[string]string) string {
|
||||
func ReplaceWithMap(str string, replaces map[string]string) string {
|
||||
for k, v := range replaces {
|
||||
str = strings.ReplaceAll(str, k, v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user