regex

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Alpha defines the alpha atom.
	// This only allows upper and lower case characters.
	Alpha = Match(`[A-Za-z]+`)

	// Numeric defines the alpha atom.
	// This only allows a non-empty sequence of digits.
	Numeric = Match(`[0-9]+`)

	// AlphaNumeric defines the alpha numeric atom, typically a
	// component of names. This only allows upper and lower case characters and digits.
	AlphaNumeric = Match(`[A-Za-z0-9]+`)

	// Identifier is an AlphaNumeric regexp starting with an Alpha regexp.
	Identifier = Sequence(Alpha, Match(`[A-Za-z0-9]`), Optional(Literal("+"), Alpha))
)

Match compiles the string to a regular expression.

Functions

func Anchored

func Anchored(res ...*regexp.Regexp) *regexp.Regexp

Anchored anchors the regular expression by adding start and end delimiters.

func Capture

func Capture(res ...*regexp.Regexp) *regexp.Regexp

Capture wraps the expression in a capturing group.

func CharSet added in v0.3.0

func CharSet(s string) *regexp.Regexp

CharSet compiles a set of matching charaters.

func Group

func Group(res ...*regexp.Regexp) *regexp.Regexp

Group wraps the regexp in a non-capturing group.

func Literal

func Literal(s string) *regexp.Regexp

Literal compiles s into a literal regular expression, escaping any regexp reserved characters.

func Optional

func Optional(res ...*regexp.Regexp) *regexp.Regexp

Optional wraps the expression in a non-capturing group and makes the production optional.

func OptionalRepeated added in v0.3.0

func OptionalRepeated(res ...*regexp.Regexp) *regexp.Regexp

OptionalRepeated wraps the regexp in a non-capturing group to get any number of matches.

func Or

func Or(res ...*regexp.Regexp) *regexp.Regexp

Or wraps alternative regexps.

func Repeated

func Repeated(res ...*regexp.Regexp) *regexp.Regexp

Repeated wraps the regexp in a non-capturing group to get one or more matches.

func Repetition added in v0.3.0

func Repetition(min, max int, res ...*regexp.Regexp) *regexp.Regexp

Repetition wraps the regexp in a non-capturing group to get a range of matches.

func Sequence

func Sequence(res ...*regexp.Regexp) *regexp.Regexp

Sequence defines a full expression, where each regular expression must follow the previous.

Types

This section is empty.

Jump to

Keyboard shortcuts

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