Documentation
¶
Overview ¶
Package compat provides a regexp2 adapter with regexp.Regexp-compatible matching method signatures.
Index ¶
- type Matcher
- type Regexp
- func (re *Regexp) Find(b []byte) []byte
- func (re *Regexp) FindAll(b []byte, n int) [][]byte
- func (re *Regexp) FindAllIndex(b []byte, n int) [][]int
- func (re *Regexp) FindAllString(s string, n int) []string
- func (re *Regexp) FindAllStringIndex(s string, n int) [][]int
- func (re *Regexp) FindAllStringSubmatch(s string, n int) [][]string
- func (re *Regexp) FindAllStringSubmatchIndex(s string, n int) [][]int
- func (re *Regexp) FindAllSubmatch(b []byte, n int) [][][]byte
- func (re *Regexp) FindAllSubmatchIndex(b []byte, n int) [][]int
- func (re *Regexp) FindIndex(b []byte) []int
- func (re *Regexp) FindReaderIndex(r io.RuneReader) []int
- func (re *Regexp) FindReaderSubmatchIndex(r io.RuneReader) []int
- func (re *Regexp) FindString(s string) string
- func (re *Regexp) FindStringIndex(s string) []int
- func (re *Regexp) FindStringSubmatch(s string) []string
- func (re *Regexp) FindStringSubmatchIndex(s string) []int
- func (re *Regexp) FindSubmatch(b []byte) [][]byte
- func (re *Regexp) FindSubmatchIndex(b []byte) []int
- func (re *Regexp) Match(b []byte) bool
- func (re *Regexp) MatchReader(r io.RuneReader) bool
- func (re *Regexp) MatchString(s string) bool
- func (re *Regexp) String() string
- func (re *Regexp) Unwrap() *regexp2.Regexp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher interface {
Match(b []byte) bool
MatchString(s string) bool
MatchReader(r io.RuneReader) bool
Find(b []byte) []byte
FindIndex(b []byte) []int
FindReaderIndex(r io.RuneReader) []int
FindReaderSubmatchIndex(r io.RuneReader) []int
FindString(s string) string
FindStringIndex(s string) []int
FindStringSubmatch(s string) []string
FindStringSubmatchIndex(s string) []int
FindSubmatch(b []byte) [][]byte
FindSubmatchIndex(b []byte) []int
FindAll(b []byte, n int) [][]byte
FindAllIndex(b []byte, n int) [][]int
FindAllString(s string, n int) []string
FindAllStringIndex(s string, n int) [][]int
FindAllStringSubmatch(s string, n int) [][]string
FindAllStringSubmatchIndex(s string, n int) [][]int
FindAllSubmatch(b []byte, n int) [][][]byte
FindAllSubmatchIndex(b []byte, n int) [][]int
}
Matcher is the common matching interface implemented by regexp.Regexp and this package's Regexp adapter.
It includes the standard-library matching surface: Match, MatchString, MatchReader, and all Find(All)?(String)?(Submatch)?(Index)? methods.
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
Regexp adapts a regexp2.Regexp to the matching method signatures of regexp.Regexp.
The wrapped regexp2 engine can return match-time errors, most commonly timeouts. Since regexp.Regexp matching methods do not return errors, this adapter panics if the wrapped regexp2 matcher returns one.
func Compile ¶
func Compile(expr string, options ...regexp2.CompileOption) (*Regexp, error)
Compile parses a regular expression and returns a compat adapter for it.
func MustCompile ¶
func MustCompile(str string, options ...regexp2.CompileOption) *Regexp
MustCompile is like Compile but panics if the expression cannot be parsed.
func (*Regexp) FindAllIndex ¶
FindAllIndex returns a slice of byte index pairs for all successive matches in b.
func (*Regexp) FindAllString ¶
FindAllString returns a slice of all successive matches in s.
func (*Regexp) FindAllStringIndex ¶
FindAllStringIndex returns a slice of byte index pairs for all successive matches in s.
func (*Regexp) FindAllStringSubmatch ¶
FindAllStringSubmatch returns a slice of all successive matches and their submatches in s.
func (*Regexp) FindAllStringSubmatchIndex ¶
FindAllStringSubmatchIndex returns a slice of byte index pairs for all successive matches and their submatches in s.
func (*Regexp) FindAllSubmatch ¶
FindAllSubmatch returns a slice of all successive matches and their submatches in b.
func (*Regexp) FindAllSubmatchIndex ¶
FindAllSubmatchIndex returns a slice of byte index pairs for all successive matches and their submatches in b.
func (*Regexp) FindIndex ¶
FindIndex returns a two-element slice defining the location of the leftmost match in b.
func (*Regexp) FindReaderIndex ¶
func (re *Regexp) FindReaderIndex(r io.RuneReader) []int
FindReaderIndex returns a two-element slice defining the byte location of the leftmost match in text read from r.
func (*Regexp) FindReaderSubmatchIndex ¶
func (re *Regexp) FindReaderSubmatchIndex(r io.RuneReader) []int
FindReaderSubmatchIndex returns a slice holding the byte index pairs of the leftmost match and its submatches in text read from r.
func (*Regexp) FindString ¶
FindString returns a string holding the text of the leftmost match in s.
func (*Regexp) FindStringIndex ¶
FindStringIndex returns a two-element slice defining the location of the leftmost match in s.
func (*Regexp) FindStringSubmatch ¶
FindStringSubmatch returns a slice of strings holding the text of the leftmost match and its submatches.
func (*Regexp) FindStringSubmatchIndex ¶
FindStringSubmatchIndex returns a slice holding the byte index pairs of the leftmost match and its submatches.
func (*Regexp) FindSubmatch ¶
FindSubmatch returns a slice of byte slices holding the text of the leftmost match and its submatches.
func (*Regexp) FindSubmatchIndex ¶
FindSubmatchIndex returns a slice holding the byte index pairs of the leftmost match and its submatches.
func (*Regexp) Match ¶
Match reports whether the byte slice b contains any match of the regular expression.
func (*Regexp) MatchReader ¶
func (re *Regexp) MatchReader(r io.RuneReader) bool
MatchReader reports whether text returned by r contains any match of the regular expression.
func (*Regexp) MatchString ¶
MatchString reports whether the string s contains any match of the regular expression.