code: func ParseLineRegex(regexStr string) (*regexp.Regexp, error) {
  	// Regex can't be blank
  	if regexStr == "" {
  		logrus.Debug("LineRegex is blank; required field")
  		return nil, errors.New("Must provide a regex for parsing log lines; use `--regex.line_regex` flag.")
  	}
  
  	// Compile regex
  	lineRegex, err := regexp.Compile(regexStr)
  	if err != nil {
  		logrus.WithFields(logrus.Fields{
  			"lineRegex": regexStr,
  		}).Error("Could not compile line regex")
  		return nil, err
  	}
  
  	// Require at least one named group
  	var numNamedGroups int
  	for _, groupName := range lineRegex.SubexpNames() {
  		if groupName != "" {
  			numNamedGroups++
  		}
  	}
  	if numNamedGroups == 0 {
  		logrus.WithFields(logrus.Fields{
  			"LineRegex": regexStr,
  		}).Error("No named capture groups")
  		return nil, errors.New(fmt.Sprintf("No named capture groups found in regex: '%s'. Must provide at least one named group with line regex. Example: `(?P<name>re)`", regexStr))
  	}
  
  	return lineRegex, nil
  }
docs: // Compile a regex & validate expectations for log line parsing