Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Default = &RegexpWriter{
MaxQuantifierLength: 5,
}
Default is an instance of RegexpWriter with the default configurtion
Functions ¶
func Reverse ¶
Reverse takes a regex pattern string and returns a string that satisfies that pattern.
Example ¶
package main
import (
"fmt"
"github.com/pipe01/revregexp"
)
func main() {
str, _ := revregexp.Reverse(`\d{5}`)
fmt.Println(str)
// Outputs: 19347
}
func ReversePattern ¶
ReversePattern takes a parsed regex pattern and returns a string that satisfies that pattern.
Example ¶
package main
import (
"fmt"
"regexp/syntax"
"github.com/pipe01/revregexp"
)
func main() {
r, _ := syntax.Parse(`\d{5}`, syntax.Perl)
str, _ := revregexp.ReversePattern(r)
fmt.Println(str)
// Outputs: 38572
}
Types ¶
type RegexpWriter ¶
type RegexpWriter struct {
MaxQuantifierLength int // The maximum length for open-ended quantifiers (*, ?, etc)
}
RegexpWriter supports converting a syntax.Regexp to a string using random values
func (*RegexpWriter) Write ¶
func (w *RegexpWriter) Write(r *syntax.Regexp, wr StringWriter) error
Click to show internal directories.
Click to hide internal directories.