Documentation ¶
Overview ¶
Package matcher provides a simple and compatible matcher interface around [Go PCRE](https://github.com/gijsbers/go-pcre).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
type Engine interface { Compile(pattern string, flags int) (Regexp, error) Quote(s string) string FlagDotAll() int FlagExtended() int FlagUnicode() int FlagCaseInsensitive() int FlagMultiline() int }
Engine represents a regexp engine
var ReEngine Engine
ReEngine contains the regexp engine which should be used for all matching; For local dev runs init this with 'matcherpcre.NewEngine()'. For production uses init it from Java with its implementation.
type Match ¶
type Match interface { // Groups returns the number of capturing groups in the pattern Groups() int // GroupByIdx returns the value of a group by index // Important: GroupByIdx(0) returns the full match, the first group has index 1 GroupByIdx(idx int) string // GroupPresentByIdx returns whether the specified group is present in the succesful match GroupPresentByIdx(idx int) bool // GroupByName returns the value of a group by name GroupByName(name string) string // GroupPresentByName returns whether the specified group is present in the succesful match GroupPresentByName(name string) bool // Next tries to find a next match, returns true if it succeeds; // after calling this method all info about the previous match gets lost Next() bool }
Match represents the result of a successful match
type Regexp ¶
type Regexp interface { // Search returns the leftmost successful match or nil if the pattern failed to match Search(subject string) Match // Replace replaces every occurrence of the pattern with repl // (group references in repl are in Perl/Java style: $0, $1, $2, ..) Replace(subject, repl string) string // ReplaceFunc replaces every occurrence of the pattern with // replacements produced by invoking the replacer on every match ReplaceFunc(subject string, replacer Replacer) string }
Regexp represents compiled regular expression
Click to show internal directories.
Click to hide internal directories.