ContainsAllWords 检查字符串是否包含所有单词
(s string, words []string, isCaseInsensitive bool)
| 73 | |
| 74 | // ContainsAllWords 检查字符串是否包含所有单词 |
| 75 | func ContainsAllWords(s string, words []string, isCaseInsensitive bool) bool { |
| 76 | var allRunes = []rune(s) |
| 77 | if len(allRunes) == 0 || len(words) == 0 { |
| 78 | return false |
| 79 | } |
| 80 | |
| 81 | for _, word := range words { |
| 82 | if result, _ := ContainsWordRunes(allRunes, []rune(word), isCaseInsensitive); !result { |
| 83 | return false |
| 84 | } |
| 85 | } |
| 86 | return true |
| 87 | } |
| 88 | |
| 89 | // ContainsWordRunes 检查字符列表是否包含某个单词子字符列表 |
| 90 | func ContainsWordRunes(allRunes []rune, subRunes []rune, isCaseInsensitive bool) (result bool, firstIndex int) { |