summaryrefslogtreecommitdiff
path: root/re.go
diff options
context:
space:
mode:
Diffstat (limited to 're.go')
-rw-r--r--re.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/re.go b/re.go
index 6584c15..714afcf 100644
--- a/re.go
+++ b/re.go
@@ -1,3 +1,22 @@
package main
-// TODO add regexp handler
+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]))
+ if len(z) < 2 {
+ return ""
+ }
+ re, err := regexp.Compile(z[0])
+ if err != nil {
+ return ""
+ }
+ return re.ReplaceAllString(s, z[1])
+}