mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-07 14:12:28 +08:00
feat: add ReplaceByMap
This commit is contained in:
@@ -525,3 +525,17 @@ func ExampleIndexOffset() {
|
||||
// -1
|
||||
// -1
|
||||
}
|
||||
|
||||
func ExampleReplaceByMap() {
|
||||
str := "ac ab ab ac"
|
||||
replaces := map[string]string{
|
||||
"a": "1",
|
||||
"b": "2",
|
||||
}
|
||||
|
||||
result := ReplaceByMap(str, replaces)
|
||||
|
||||
fmt.Println(result)
|
||||
// Output:
|
||||
// 1c 12 12 1c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user