#Regexp Factors
Installation
$ go get github.com/ikawaha/regexp/...
To draw parse trees, demo application uses graphviz . You need graphviz installed.
Usage
$ refact
usage: refact regexp
refact -http=:6060
-http string
HTTP service address (e.g. ':6060')
Web App
Programing Example
package main
import (
"fmt"
"os"
"regexp/syntax"
"github.com/ikawaha/regexp/factor"
)
func main() {
if len(os.Args) != 2 {
os.Exit(2)
}
re, err := syntax.Parse(os.Args[1], syntax.Perl)
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
return
}
f := factor.Analyze(re)
fmt.Println("Exact", f.Exact)
fmt.Println("Prefix", f.Prefix)
fmt.Println("Suffix", f.Suffix)
fmt.Println("Fact", f.Fact)
}