diff options
Diffstat (limited to 'funcs/regexp.go')
| -rw-r--r-- | funcs/regexp.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/funcs/regexp.go b/funcs/regexp.go new file mode 100644 index 00000000..8b5983a7 --- /dev/null +++ b/funcs/regexp.go @@ -0,0 +1,36 @@ +package funcs + +import ( + "sync" + + "github.com/hairyhenderson/gomplate/regexp" +) + +var ( + reNS *ReFuncs + reNSInit sync.Once +) + +// ReNS - +func ReNS() *ReFuncs { + reNSInit.Do(func() { reNS = &ReFuncs{} }) + return reNS +} + +// AddReFuncs - +func AddReFuncs(f map[string]interface{}) { + f["regexp"] = ReNS +} + +// ReFuncs - +type ReFuncs struct{} + +// Replace - +func (f *ReFuncs) Replace(re, replacement, input string) string { + return regexp.Replace(re, replacement, input) +} + +// Match - +func (f *ReFuncs) Match(re, input string) bool { + return regexp.Match(re, input) +} |
