예제 #1
0
func RegExHasSuffix(re *regexp.Regexp, s string) []string {
	if s == "" {
		return make([]string, 0)
	}
	re.Longest()
	outs := re.FindAllStringSubmatch(s, -1)
	newOuts := make([]string, 0)
	if len(outs) > 0 {
		inOuts := outs[0]
		ref := inOuts[0]
		for _, out := range inOuts {
			if out != "" && strings.HasPrefix(s, ref) && strings.HasPrefix(ref, out) {
				newOuts = append(newOuts, strings.TrimSpace(out))
			}
		}
	}
	return newOuts
}