diff --git a/v2/pkg/generators/dsl.go b/v2/pkg/generators/dsl.go index 1009a253..301d60c5 100644 --- a/v2/pkg/generators/dsl.go +++ b/v2/pkg/generators/dsl.go @@ -13,7 +13,7 @@ import ( "net/url" "regexp" "strings" - + "github.com/Knetic/govaluate" "github.com/spaolacci/murmur3" ) @@ -47,7 +47,11 @@ func HelperFunctions() (functions map[string]govaluate.ExpressionFunction) { } functions["replace"] = func(args ...interface{}) (interface{}, error) { - return strings.ReplaceAll(args[0].(string), args[1].(string), args[2].(string)), nil + compiled, err := regexp.Compile(args[1].(string)) + if err != nil { + return nil, err + } + return compiled.ReplaceAllString(args[0].(string), args[2].(string)), nil } functions["trim"] = func(args ...interface{}) (interface{}, error) {