summaryrefslogtreecommitdiff
path: root/re.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-07-06 17:17:46 +0200
committerDimitri Sokolyuk <demon@dim13.org>2019-07-06 17:17:46 +0200
commit1d2ca509c77cbb2af0475b1319cd840f8ce9a1d0 (patch)
tree05a838baaf4f96fbcce03d06090a2403ee56c878 /re.go
parent87e820722cf02054225b47a58f97d0824118292f (diff)
Split in packages
Diffstat (limited to 're.go')
-rw-r--r--re.go36
1 files changed, 0 insertions, 36 deletions
diff --git a/re.go b/re.go
deleted file mode 100644
index fab6386..0000000
--- a/re.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package main
-
-import (
- "errors"
- "regexp"
- "strings"
-)
-
-var errNotRE = errors.New("not re")
-
-func re(s, r string, global bool) (string, error) {
- // min: at least two separators
- if len(r) < 2 {
- return "", errNotRE
- }
- z := strings.Split(r[1:], string(r[0]))
- // match // and ///
- if len(z) < 2 || len(z) > 3 {
- return "", errNotRE
- }
- re, err := regexp.Compile(z[0])
- if err != nil {
- return "", err
- }
- i := 1
- if global {
- i = -1
- }
- return re.ReplaceAllStringFunc(s, func(b string) string {
- if i != 0 {
- i--
- return z[1]
- }
- return b
- }), nil
-}