first commit
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user