Skip to content

Commit

Permalink
add string matching e.g 'like %str%'
Browse files Browse the repository at this point in the history
  • Loading branch information
baxiry committed Jun 22, 2024
1 parent 3e166f8 commit 0ce5a4f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions engine/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package engine

import (
"fmt"
"strings"

"github.com/tidwall/gjson"
)
Expand Down Expand Up @@ -66,6 +67,24 @@ func match(filter gjson.Result, data string) (result bool, err error) {
result = false
return result

case "$st": // is start with
if !strings.HasPrefix(dv.String(), sqv.String()) {
result = false
}
return result

case "$en": // is end with
if !strings.HasSuffix(dv.String(), sqv.String()) {
result = false
}
return result

case "$c": // is contains
if !strings.Contains(dv.String(), sqv.String()) {
result = false
}
return result

default:
err = fmt.Errorf("unknown %s operation", sqk.Value())
//fmt.Println("..wher here", sqk.Value(), sqk.Type)
Expand Down

0 comments on commit 0ce5a4f

Please sign in to comment.