residentsleeper/scripting/regexp/regexp.go
Tyler b52b38179a
Some checks failed
continuous-integration/drone/push Build is failing
Major updates/patches, functionality, api
2020-07-09 21:01:29 -04:00

31 lines
470 B
Go

package regexp
import (
lua "github.com/yuin/gopher-lua"
luar "layeh.com/gopher-luar"
"regexp"
)
func Loader(L *lua.LState) int {
// register functions to the table
mod := L.SetFuncs(L.NewTable(), exports)
// returns the module
L.Push(mod)
return 1
}
var exports = map[string]lua.LGFunction{
"MustCompile": compileFunc,
}
func compileFunc(L *lua.LState) int {
str := L.CheckString(1)
re := regexp.MustCompile(str)
L.Push(luar.New(L, re))
return 1
}