Documentation
¶
Overview ¶
Package regen is a tool for generating random strings from Go/RE2 regular expressions. It is based on homonymous CLI tool originally developed by by Noel Cower.
Index ¶
Constants ¶
const DefaultUnboundLimit int = 32
Default maximum number of repetitions allowed for patterns with unbound quantifiers
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Xeger ¶ added in v1.0.2
type Xeger struct {
// contains filtered or unexported fields
}
A Xeger is a regex-based string generator.
The zero value for Xeger holds no patterns and has the default limit for unbound quantifiers expansion.
All Xeger methods are safe for concurrent use by multiple goroutines.
func FromPattern ¶ added in v1.0.2
FromPattern attempts to parse the pattern assuming it has Perl-like syntax.
Returns a ready-to-use instance of Xeger or nil if expression can not be parsed.
func (*Xeger) AddPattern ¶ added in v1.0.2
AddPattern attempts to parse the pattern and add it to the Xeger instance.
- mode is used to specify parser flags
- simplify controls whether parsed expression should be simplified using syntax.Regexp.Simplify
func (*Xeger) Generate ¶ added in v1.0.2
Generate attempts to generate a string using a pattern from Xeger instance. If multiple patterns are held by Xeger instance, a random one is selected.
func (*Xeger) MustGenerate ¶ added in v1.0.2
MustGenerate attempts to generate a string using a pattern from Xeger instance. If multiple patterns are held by Xeger instance, a random one is selected.
Returns an empty string if any errors occur (including the case when Xeger instance does not hold any pattern)
func (*Xeger) SetUnboundLimit ¶ added in v1.0.2
SetUnboundLimit is used to update the maximum number of repetitions allowed for patterns with unbound quantifiers.