blob: 9429ac8dc210fe02630b0f4ffc379c63a68dd1e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package main
import (
"regexp"
"strings"
)
func re(s, r string) string {
// min: s//
if len(s) < 3 {
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])
}
|