mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-08 08:00:26 +08:00
优化代码
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
var whitespaceReg = regexp.MustCompile(`\s+`)
|
||||
|
||||
// 关键词匹配
|
||||
// MatchKeyword 关键词匹配
|
||||
func MatchKeyword(source, keyword string) bool {
|
||||
if len(keyword) == 0 {
|
||||
return false
|
||||
@@ -16,7 +16,7 @@ func MatchKeyword(source, keyword string) bool {
|
||||
pieces := whitespaceReg.Split(keyword, -1)
|
||||
source = strings.ToLower(source)
|
||||
for _, piece := range pieces {
|
||||
if strings.Index(source, strings.ToLower(piece)) > -1 {
|
||||
if strings.Contains(source, strings.ToLower(piece)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user