Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MatchLogic ¶
type MatchLogic int
const ( MatchValuesOr MatchLogic = 1 MatchValuesAnd MatchLogic = 2 )
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is used for strings match ,and it supports regex, wildcard. A Matcher includes several strings, regex patterns, wildcard patterns for building, and then accept one string for matching. The methods of Matcher are all not thread-safe.
func NewMatcher ¶
NewMatcher accept options for match action. Set WithMatchCaseSensitive for if case-sensitive when do matching. Set WithMatchLogic for match action with "or" and "and" logic operation.
func (*Matcher) Append ¶
Append will insert a pattern into Matcher. The type of pattern is auto recognized in follow rules:
/^regex$/ the pattern start and end with "/" means it's a regex.
%wild*card% the pattern start and end with "%" means it's a wildcard.
string otherwise, it's a string.
type Option ¶
type Option func(*Matcher)
func WithMatchCaseSensitive ¶
WithMatchCaseSensitive defines if case-sensitive when do matching. The default value is false.
func WithMatchLogic ¶
func WithMatchLogic(logic MatchLogic) Option
WithMatchLogic defines match logic between patterns in Matcher. It's effective when regex or wildcard is not empty. The normal string matching will not use this option. The default value is MatchValuesOr.