mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Make the replace function of the eval language accepting regex
This commit is contained in:
@ -3,6 +3,7 @@ package obiseq
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -204,6 +205,8 @@ var OBILang = gval.NewLanguage(
|
||||
return scomp, nil
|
||||
}),
|
||||
gval.Function("replace", func(args ...interface{}) (interface{}, error) {
|
||||
return strings.ReplaceAll(args[0].(string), args[1].(string), args[2].(string)), nil
|
||||
pattern := regexp.MustCompile(args[1].(string))
|
||||
results := pattern.ReplaceAllString(args[0].(string), args[2].(string))
|
||||
return results, nil
|
||||
}),
|
||||
)
|
||||
|
Reference in New Issue
Block a user