增加判断字符串是否包含子串方法

This commit is contained in:
2024-04-19 18:39:25 +08:00
parent e125c7e75d
commit ee726ea6bc
3 changed files with 24 additions and 2 deletions

View File

@ -1157,3 +1157,21 @@ func (str String) ReplaceChar(charTable map[string]string) String {
}
return String(formatStr)
}
// HasSubStr 是否包含指定的子串
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 18:37 2024/4/19
func (str String) HasSubStr(subStrList []string) bool {
if len(subStrList) == 0 {
return true
}
v := str.Value()
for _, item := range subStrList {
if strings.Contains(v, item) {
return true
}
}
return false
}