Skip to content
Snippets Groups Projects
Commit cfa42ff2 authored by Christoph Petrausch's avatar Christoph Petrausch
Browse files

revert regex implementation

parent aae72890
No related branches found
No related tags found
No related merge requests found
......@@ -2,13 +2,10 @@ package packet
import (
"fmt"
"regexp"
"strconv"
"strings"
)
var largeCommunityRegEx = regexp.MustCompile("^\\(?\\d+,\\d+,\\d+\\)?$")
type LargeCommunity struct {
GlobalAdministrator uint32
DataPart1 uint32
......@@ -20,12 +17,13 @@ func (c LargeCommunity) String() string {
}
func ParseLargeCommunityString(s string) (com LargeCommunity, err error) {
if !largeCommunityRegEx.Match([]byte(s)) {
return com, fmt.Errorf("malformed large community string %s", s)
}
s = strings.Trim(s, "()")
t := strings.Split(s, ",")
if len(t) != 3 {
return com, fmt.Errorf("can not parse large community %s", s)
}
v, err := strconv.ParseUint(t[0], 10, 32)
if err != nil {
return com, err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment