Version: v0.0.0-...-b52843e Latest Latest

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

Go to latest
Published: Oct 22, 2014 License: BSD-3-Clause Imports: 5 Imported by: 1




This section is empty.


View Source
var (
	HexDigit      = RxElement(`[0-9a-f]`)
	HexNumber     = Some(HexDigit)
	DecimalDigit  = RxElement(`\d`)
	DecimalNumber = Some(DecimalDigit)
	WordChar      = RxElement(`\w`)
	Word          = Some(WordChar)
	Base64Char    = RxElement(`[./a-zA-Z0-9_-]`)
	Base64        = Sequence(Some(Base64Char), Any(`=`))
	Beginning     = RxElement(`^`)
	End           = RxElement(`$`)
	AnyWhitespace = RxElement(`\s*`)

Just some elements, this should be more complete


This section is empty.


type File

type File struct {
	Package   string
	Variables []*Variable

func NewFile

func NewFile(pkg string, vars ...*Variable) *File

func (*File) Add

func (f *File) Add(v *Variable)

func (*File) Get

func (f *File) Get(name string) *Variable

func (*File) String

func (f *File) String() string

type RxElement

type RxElement string

A regexp sub-expression

func Alternation

func Alternation(elts ...RxElement) RxElement

Regexp alternation

func Anchor

func Anchor(elts ...RxElement) RxElement

Return a sequence, anchored at the beginning and end

func Any

func Any(elts ...RxElement) RxElement

Add "*" modifier to sequence of elts

func Capture

func Capture(name string, elt RxElement) RxElement

Wrap rx in a named capturing group

func Element

func Element(v interface{}) RxElement

Convert any value to RxElement

func Group

func Group(elt RxElement) RxElement

Wrap rx in a non-capturing group

func Join

func Join(glue string, elts []RxElement) RxElement

Wrap all elts in capturing groups, join with glue (only "|" or "" seem to make much sense), wrap whole thing with another non-capturing group

func Literal

func Literal(str string) RxElement

Quotes str as literal substring

func Mod

func Mod(elt RxElement, modifier string) RxElement

Modify (with "*", "*?", "+", "?" etc)

func Optional

func Optional(elts ...RxElement) RxElement

Add "?" modifier to sequence of elts

func Sequence

func Sequence(elts ...RxElement) RxElement

Sequence of regexps

func Some

func Some(elts ...RxElement) RxElement

Add "+" modifier to sequence of elts

func TrimAnchor

func TrimAnchor(elts ...RxElement) RxElement

Return a sequence, anchored at the beginning and end, trimming (i.e. matching and not capturing) leading and trailing whitespace

type Variable

type Variable struct {
	Name string

A variable is a named regexp. It is translated to a `*regexp.Regexp` variable and constants enumerating named captures.

func MustVariable

func MustVariable(name string, elements ...RxElement) *Variable

Returns new variable object, panics on error

func NewVariable

func NewVariable(name string, elements ...RxElement) (*Variable, error)

Returns new variable object or error

func (*Variable) String

func (vrbl *Variable) String() string

Jump to

Keyboard shortcuts

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