policy: remove unnecessary regexp special charactor

Since communities/ext-communities are tested one by one in policy-condition,
we don't need '^' and '$' around match condition items.

Signed-off-by: ISHIDA Wataru <[email protected]>
This commit is contained in:
ISHIDA Wataru
2016-02-19 15:53:05 +09:00
parent 646860e9d1
commit 76525a966b
+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)