mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 21:50:26 +08:00 
			
		
		
		
	
		
			
	
	
		
			26 lines
		
	
	
		
			419 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			419 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package configutils
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"regexp"
							 | 
						||
| 
								 | 
							
									"strings"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var whitespaceReg = regexp.MustCompile(`\s+`)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 关键词匹配
							 | 
						||
| 
								 | 
							
								func MatchKeyword(source, keyword string) bool {
							 | 
						||
| 
								 | 
							
									if len(keyword) == 0 {
							 | 
						||
| 
								 | 
							
										return false
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									pieces := whitespaceReg.Split(keyword, -1)
							 | 
						||
| 
								 | 
							
									source = strings.ToLower(source)
							 | 
						||
| 
								 | 
							
									for _, piece := range pieces {
							 | 
						||
| 
								 | 
							
										if strings.Index(source, strings.ToLower(piece)) > -1 {
							 | 
						||
| 
								 | 
							
											return true
							 | 
						||
| 
								 | 
							
										}
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									return false
							 | 
						||
| 
								 | 
							
								}
							 |