Replace the regular implementation of the filter for proxy-providers and proxy-groups with regex2

This commit is contained in:
admin
2022-02-16 22:18:05 +08:00
parent 847c91503b
commit 27292dac0c
4 changed files with 16 additions and 8 deletions

View File

@ -2,7 +2,7 @@ package outboundgroup
import (
"github.com/Dreamacro/clash/tunnel"
"regexp"
"github.com/dlclark/regexp2"
"time"
C "github.com/Dreamacro/clash/constant"
@ -23,12 +23,14 @@ func getProvidersProxies(providers []provider.ProxyProvider, touch bool, filter
}
}
var filterReg *regexp.Regexp = nil
matchedProxies := []C.Proxy{}
var filterReg *regexp2.Regexp = nil
var matchedProxies []C.Proxy
if len(filter) > 0 {
filterReg = regexp.MustCompile(filter)
//filterReg = regexp.MustCompile(filter)
filterReg = regexp2.MustCompile(filter, 0)
for _, p := range proxies {
if filterReg.MatchString(p.Name()) {
//if filterReg.MatchString(p.Name()) {
if mat, _ := filterReg.FindStringMatch(p.Name()); mat != nil {
matchedProxies = append(matchedProxies, p)
}
}