code: func (r *rule) sub(text string) string {
  	if !r.pattern.MatchString(text) {
  		return text
  	}
  
  	orig := len(text)
  	diff := 0
  	for _, submat := range r.pattern.FindAllStringSubmatchIndex(text, -1) {
  		for idx, mat := range submat {
  			if mat != -1 && idx > 0 && idx%2 == 0 {
  				loc := []int{mat - diff, submat[idx+1] - diff}
  				text = text[:loc[0]] + r.replacement + text[loc[1]:]
  				diff = orig - len(text)
  			}
  		}
  	}
  
  	return text
  }
docs: // sub replaces all occurrences of Pattern with Replacement.