pattern

package
v0.0.0-...-678bb0e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pattern implements lightweight parsable string patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pattern

type Pattern interface {
	// String returns the definition of the pattern parsable by Parse.
	String() string
	// Match returns true if s matches this pattern, otherwise false.
	Match(s string) bool
}

Pattern can either match or not match a string.

var (
	// Any matches anything.
	Any Pattern
	// None matches nothing.
	None Pattern
)

func Exact

func Exact(s string) Pattern

Exact returns a pattern that matches s only.

func Parse

func Parse(s string) (Pattern, error)

Parse parses a pattern.

Ordered by precedence, s can be:

  • "": matches nothing
  • "*": matches anything
  • "<S>" where S does not have a colon: same as "exact:<S>"
  • "exact:<S>": matches only string S
  • "text:<S>": same as "exact:<S>" for backward compatibility
  • "regex:<E>": matches all strings matching regular expression E

Anything else will cause an error.

func Regexp

func Regexp(expr *regexp.Regexp) Pattern

Regexp returns a regular expression-based pattern.

Jump to

Keyboard shortcuts

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