Libbeat common.Match not work with case insensitive

beats document said filebeat suppport "(?i)" regexp

I read the beats code,found it depend on beats/libbeat/common/match,
but I found beats/libbeat/common/match does not work with "(?i)" option
version: GitHub - elastic/beats: 🐠 Beats - Lightweight shippers for Elasticsearch & Logstash v7.3.0
output:

not match
match

code:

package main

import (
	"fmt"
	"log"
	"regexp"

	"github.com/elastic/beats/libbeat/common/match"
)

func main() {
	pattern := `(?i)warning`
	str := `warning`
	m, err := match.Compile(pattern)
	if err != nil {
		log.Fatal(err.Error())
	}
	if m.MatchString(str) {
		fmt.Println("match")
	} else {
		fmt.Println("not match")
	}
	m2, err := regexp.Compile(pattern)
	if err != nil {
		log.Fatal(err.Error())
	}
	ok := m2.MatchString(str)
	if ok {
		fmt.Println("match")
	} else {
		fmt.Println("not match")
	}
}

I was able to reproduce this. I opened PR #13250 with a fix.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.