Revert "policy: remove unnecessary regexp special charactor"

This reverts commit 76525a966b.
This commit is contained in:
tamihiro
2016-04-20 12:19:35 +09:00
committed by FUJITA Tomonori
parent e06bb04f14
commit b7543a5ae0
+3 -3
View File
@@ -879,14 +879,14 @@ func ParseExtCommunity(arg string) (bgp.ExtendedCommunityInterface, error) {
func ParseCommunityRegexp(arg string) (*regexp.Regexp, error) {
i, err := strconv.Atoi(arg)
if err == nil {
return regexp.MustCompile(fmt.Sprintf("%d:%d", i>>16, i&0x0000ffff)), nil
return regexp.MustCompile(fmt.Sprintf("^%d:%d$", i>>16, i&0x0000ffff)), nil
}
if regexp.MustCompile("(\\d+.)*\\d+:\\d+").MatchString(arg) {
return regexp.MustCompile(fmt.Sprintf("%s", arg)), nil
return regexp.MustCompile(fmt.Sprintf("^%s$", arg)), nil
}
for i, v := range bgp.WellKnownCommunityNameMap {
if strings.Replace(strings.ToLower(arg), "_", "-", -1) == v {
return regexp.MustCompile(fmt.Sprintf("%d:%d", i>>16, i&0x0000ffff)), nil
return regexp.MustCompile(fmt.Sprintf("^%d:%d$", i>>16, i&0x0000ffff)), nil
}
}
exp, err := regexp.Compile(arg)