crun

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 7 Imported by: 5

README

Generate matching strings based on regular expressions

Build Status Go Report Card GoDoc GitHub license gocover.io

Example

# Generates a number of all possible combinations of 1 to 6 digits in length
> crun "\d{1,6}"

# Generate random 5 possibilities
> crun -r -l 5 "(root|admin):[0-9]{4,5}"

Download & Install

go get -u -v github.com/wzshiming/crun/cmd/crun

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

View Source
const MoreTimes = 18

MoreTimes Maximum omitted default value

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op uint8

An Op is a single regular expression operator.

const (
	OpLiteral Op
	OpRepeat
	OpAlternate
)

Operators are listed in precedence order, tightest binding to weakest.

func (Op) String

func (i Op) String() string

type Optional added in v0.3.3

type Optional struct {
	MoreTimes    int
	AnyCharNotNL []rune
	AnyChar      []rune
	Rand         Rand
}

Optional is optional related option for regexps

func (*Optional) NewRegexps added in v0.3.3

func (o *Optional) NewRegexps(reg *syntax.Regexp) (out Regexps)

NewRegexps returns regexps translated from regexp/syntax

type Rand added in v0.4.0

type Rand interface {
	Int() int
}

type Regexp

type Regexp struct {
	Op       Op
	Sub      []Regexps
	Rune     []rune
	Min, Max int
}

Regexp syntax tree translated from regexp/syntax

type Regexps

type Regexps []*Regexp

Regexps syntax tree translated from regexp/syntax

func Compile added in v0.3.0

func Compile(str string) (Regexps, error)

Compile parses a regular expression and returns.

func MustCompile added in v0.3.0

func MustCompile(str string) Regexps

MustCompile is like Compile but panics if the expression cannot be parsed. It simplifies safe initialization of global variables holding compiled regular expressions.

func NewRegexps added in v0.3.0

func NewRegexps(reg *syntax.Regexp) (out Regexps)

NewRegexps returns regexps translated from regexp/syntax

func (Regexps) Rand

func (r Regexps) Rand() string

Rand possibilities

func (Regexps) RandSource added in v0.4.0

func (r Regexps) RandSource(rand Rand) string

RandSource possibilities

func (Regexps) RandSourceWithRunes added in v0.4.0

func (r Regexps) RandSourceWithRunes(rand Rand) []rune

RandSourceWithRunes possibilities

func (Regexps) RandWithRunes added in v0.3.3

func (r Regexps) RandWithRunes() []rune

RandWithRunes possibilities

func (Regexps) Range

func (r Regexps) Range(f func(string) bool) bool

Range all possibilities

func (Regexps) RangeWithRunes added in v0.3.3

func (r Regexps) RangeWithRunes(f func([]rune) bool) bool

RangeWithRuns all possibilities

func (Regexps) Size

func (r Regexps) Size() int

Size The number of possibilities that can match regularity

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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