regexputil

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package regexputil implements some introspection on parsed regexps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Regexp

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

Regexp represents a parsed regexp. Use Parse to make one.

func Parse

func Parse(regexp string) (Regexp, error)

Parse takes a regexp in Perl syntax (as implemented by regexp/syntax) and returns a Regexp, for introspecting the regexp.

func (Regexp) List

func (r Regexp) List() ([]string, bool)

List returns a list of fixed matches if the regexp only matches a fixed set of alternate strings.

func (Regexp) Wildcard

func (r Regexp) Wildcard() (string, bool)

Wildcard attempts to convert the regexp into a wildcard form, that is, if it can be represented as a glob pattern using only "*", it will return "string*" and true. It is assumed the "*" glob character matches 0 or more characters only (i.e. is exactly identical to ".*"). Literal strings (i.e. not containing any "*") will also be returned, if you need to handle these differently it is recommended to call List first.

Jump to

Keyboard shortcuts

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