first commit

This commit is contained in:
cdle
2023-06-01 08:41:54 +08:00
parent 61b0e99833
commit d253ed8d5b
80 changed files with 14245 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
package core
import (
"regexp"
"github.com/dop251/goja"
)
func Regexp(call goja.ConstructorCall) *goja.Object {
pattern := call.Arguments[0].String()
call.This.Set("find", regexp.MustCompile(pattern).FindString)
call.This.Set("findSubmatch", regexp.MustCompile(pattern).FindStringSubmatch)
call.This.Set("findAll", regexp.MustCompile(pattern).FindAllString)
call.This.Set("findAllSubmatch", regexp.MustCompile(pattern).FindAllStringSubmatch)
call.This.Set("replaceAll", regexp.MustCompile(pattern).ReplaceAllString)
return nil
}