1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 14:42:27 +08:00

feat: add ContainsAll and ContainsAny

This commit is contained in:
dudaodong
2023-05-31 10:51:16 +08:00
parent 09ec5b97a6
commit 2894bec80c
3 changed files with 71 additions and 0 deletions

View File

@@ -528,3 +528,27 @@ func HideString(origin string, start, end int, replaceChar string) string {
return startStr + replaceStr + endStr
}
// ContainsAll return true if target string contains all the substrs.
// Play: todo
func ContainsAll(str string, substrs []string) bool {
for _, v := range substrs {
if !strings.Contains(str, v) {
return false
}
}
return true
}
// ContainsAny return true if target string contains any one of the substrs.
// Play: todo
func ContainsAny(str string, substrs []string) bool {
for _, v := range substrs {
if strings.Contains(str, v) {
return true
}
}
return false
}