package main import ( "regexp" "strings" ) func re(s, r string) string { // min: s// if len(r) < 3 || r[0] != 's' { return "" } z := strings.Split(r[2:], string(r[1])) // match s// and s/// if len(z) < 2 || len(z) > 3 { return "" } re, err := regexp.Compile(z[0]) if err != nil { return "" } return re.ReplaceAllString(s, z[1]) }