Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrValues ¶
GetOrValues returns "or" values from the given regexp expr.
It ignores start and end anchors ('^') and ('$') at the start and the end of expr. It returns ["foo", "bar"] for "foo|bar" regexp. It returns ["foo"] for "foo" regexp. It returns [""] for "" regexp. It returns an empty list if it is impossible to extract "or" values from the regexp.
func RemoveStartEndAnchors ¶
RemoveStartEndAnchors removes '^' at the start of expr and '$' at the end of the expr.
func Simplify ¶
Simplify simplifies the given expr.
It returns plaintext prefix and the remaining regular expression with dropped '^' and '$' anchors at the beginning and the end of the regular expression.
The function removes capturing parens from the expr, so it cannot be used when capturing parens are necessary.
Types ¶
type PromRegex ¶
type PromRegex struct {
// contains filtered or unexported fields
}
PromRegex implements an optimized string matching for Prometheus-like regex.
The following regexs are optimized:
- plain string such as "foobar" - alternate strings such as "foo|bar|baz" - prefix match such as "foo.*" or "foo.+" - substring match such as ".*foo.*" or ".+bar.+"
The rest of regexps are also optimized by returning cached match results for the same input strings.
func NewPromRegex ¶
NewPromRegex returns PromRegex for the given expr.
func (*PromRegex) MatchString ¶
MatchString returns true if s matches pr.
The pr is automatically anchored to the beginning and to the end of the matching string with '^' and '$'.