in user-center-slack/importer.go [43:67]
func (uc *UserCenter) parseText(text string) (string, string, []string, error) {
re := regexp.MustCompile(`\[(.*?)\]`)
matches := re.FindAllStringSubmatch(text, -1)
if len(matches) != 3 {
return "", "", nil, fmt.Errorf("text field does not conform to the required format")
}
part1 := matches[0][1]
part2 := matches[1][1]
rawTags := strings.Split(matches[2][1], ",")
var tags []string
for _, tag := range rawTags {
if tag != "" {
tags = append(tags, tag)
}
}
// if part1 or part2 or tags in empty return error
if part1 == "" || part2 == "" || len(tags) == 0 {
return "", "", nil, fmt.Errorf("text field does not be empty")
}
return part1, part2, tags, nil
}