regex

package
v1.104.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Regex

type Regex interface {
	FindStringSubmatch(ctx context.Context, s string) []string
	MatchString(ctx context.Context, s string) bool
	String() string
}

Regex interface to use regexp.Regexp and regexp2.Regexp interchangeably.

func Compile

func Compile(s string) (Regex, error)

Compile compiles via standard regexp package. Upon failure, it will also attempt compilation via regexp2 package.

func MustCompile

func MustCompile(s string) Regex

MustCompile compiles via standard regexp package. Upon failure, it will also attempt compilation via regexp2 package. Will panic, if both compilation attempts failed.

type RegexpWrap added in v1.104.0

type RegexpWrap struct {
	// contains filtered or unexported fields
}

RegexpWrap is a wrapper around regexp.Regexp, which conforms to regexp.Regexp interface. Only supports a subset of methods.

func NewRegexpWrap added in v1.104.0

func NewRegexpWrap(rgx *regexp.Regexp) *RegexpWrap

NewRegexpWrap returns a new instance of regexpWrap.

func (*RegexpWrap) FindStringSubmatch added in v1.104.0

func (re *RegexpWrap) FindStringSubmatch(_ context.Context, s string) []string

FindStringSubmatch returns a slice of strings holding the text of the leftmost match of the regular expression in s and the matches, if any, of its subexpressions, as defined by the 'Submatch' description in the package comment. A return value of nil indicates no match.

func (*RegexpWrap) MatchString added in v1.104.0

func (re *RegexpWrap) MatchString(_ context.Context, s string) bool

MatchString reports whether the string s contains any match of the regular expression re.

func (*RegexpWrap) String added in v1.104.0

func (re *RegexpWrap) String() string

String returns the source text used to compile the regular expression.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL