mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 05:00:24 +08:00 
			
		
		
		
	优化IP库模板分析程序
This commit is contained in:
		@@ -38,7 +38,7 @@ func (this *Template) init() error {
 | 
			
		||||
 | 
			
		||||
		return keyword
 | 
			
		||||
	})
 | 
			
		||||
	reg, err := regexp.Compile("^(?U)" + template)
 | 
			
		||||
	reg, err := regexp.Compile("^(?U)" + template + "\n?$")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,14 +13,15 @@ func TestNewTemplate(t *testing.T) {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	for _, s := range []string{
 | 
			
		||||
		"0.0.0.0|0.255.255.255|0|0|0|内网IP|内网IP",
 | 
			
		||||
		"42.0.32.0|42.0.63.255|中国|0|广东省|广州市|电信",
 | 
			
		||||
		"42.0.32.0|42.0.63.255|中国|0|广东省|广州市|电信\n123",
 | 
			
		||||
		"42.0.32.0|42.0.63.255|中国||广东省|广州市|电信",
 | 
			
		||||
		"42.0.32.0|42.0.63.255|中国|0||广州市|电信",
 | 
			
		||||
		"42.0.32.0|42.0.63.255|中国|0|广东省|广州市",
 | 
			
		||||
	} {
 | 
			
		||||
		values, _ := template.Extract(s, []string{})
 | 
			
		||||
		t.Log(s, "=>\n", values)
 | 
			
		||||
		values, ok := template.Extract(s, []string{})
 | 
			
		||||
		t.Log(ok, s, "=>\n", values)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user