regen

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 4 Imported by: 0

README

regen

GoDoc

regen is a go library that creates random strings based on regular expressions.

usage

  • limit is the maximum number of times *, + or repeat.
    values smaller than 0 default to 10.
package main

import (
	"fmt"

	"github.com/di-wu/regen"
)

func main() {
    g, err := regen.New(`[01]{5}`)
    if err != nil {
        panic(err)
    }
    for i := 0; i < 5; i++ {
        fmt.Println(g.Generate())
    }
}
00001
01000
11101
11000
10000
cli
  • regex (string): regex used to generate strings
  • seed (int64) : a certain seed to generate strings
  • limit (int) : the amount of iterations of *, + and repetitions
  • n (int) : number of regex strings to generate
go run cli/cli.go -regex="[01]{5}" -n=5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

func New

func New(regexp string) (*Generator, error)

Creates a new generator with given string. Returns an error if the regexp is not valid.

func (*Generator) Generate

func (g *Generator) Generate() string

Generate a random string based on the regexp of the generator.

func (*Generator) Limit

func (g *Generator) Limit(value int)

Limit the amount of iterations of *, + and repetitions.

func (*Generator) Seed

func (g *Generator) Seed(seed int64)

Use a certain seed to generate strings.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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