https://github.com/alixaxel/genex
Genex package for Go
https://github.com/alixaxel/genex
genex go golang regex regular-expression
Last synced: 9 months ago
JSON representation
Genex package for Go
- Host: GitHub
- URL: https://github.com/alixaxel/genex
- Owner: alixaxel
- License: mit
- Created: 2015-03-09T19:24:16.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-01-05T18:10:35.000Z (almost 6 years ago)
- Last Synced: 2025-03-17T14:22:13.800Z (9 months ago)
- Topics: genex, go, golang, regex, regular-expression
- Language: Go
- Homepage: https://namegrep.com/
- Size: 12.7 KB
- Stars: 76
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-go - genex - | - | - | (Text Processing / HTTP Clients)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- awesome-go-cn - genex
- awesome-go-cn - genex
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. - :arrow_down:0 - :star:36 (Text Processing / HTTP Clients)
- awesome-go-zh - genex
- awesome-go - genex - Genex package for Go - ★ 48 (Text Processing)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Advanced Console UIs)
- fucking-awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- awesome-go-extra - genex - 03-09T19:24:16Z|2020-01-05T18:10:35Z| (Bot Building / Regular Expressions)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (<span id="文字处理-text-processing">文字处理 Text Processing</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- fucking-awesome-go - :octocat: genex - Count and expand Regular Expressions into all matching Strings :star: 36 :fork_and_knife: 3 (Text Processing / Advanced Console UIs)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / HTTP Clients)
- awesome-go-cn - genex
- awesome-go-with-stars - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- awesome-Char - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / HTTP Clients)
- zero-alloc-awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
- awesome-go-cn - genex
- awesome-go-plus - genex - Count and expand Regular Expressions into all matching Strings.  (Text Processing / Regular Expressions)
- awesome-go - genex - Count and expand Regular Expressions into all matching Strings. (Text Processing / Regular Expressions)
README
# genex [](https://godoc.org/github.com/alixaxel/genex) [](http://gocover.io/github.com/alixaxel/genex) [](https://goreportcard.com/report/github.com/alixaxel/genex)
Genex package for Go
Easy and efficient package to expand any given regex into all the possible strings that it can match.
This is the code that powers [namegrep](https://namegrep.com/).
## Usage
```go
package main
import (
"fmt"
"regexp/syntax"
"github.com/alixaxel/genex"
)
func main() {
charset, _ := syntax.Parse(`[0-9a-z]`, syntax.Perl)
if input, err := syntax.Parse(`(foo|bar|baz){1,2}\d`, syntax.Perl); err == nil {
fmt.Println("Count:", genex.Count(input, charset, 3))
genex.Generate(input, charset, 3, func(output string) {
fmt.Println("[*]", output)
})
}
}
```
## Output
```
Count: 120
[*] foo0
[*] ...
[*] foo9
[*] foofoo0
[*] ...
[*] foofoo9
[*] foobar0
[*] ...
[*] foobar9
[*] foobaz0
[*] ...
[*] foobaz9
[*] bar0
[*] ...
[*] bar9
[*] barfoo0
[*] ...
[*] barfoo9
[*] barbar0
[*] ...
[*] barbar9
[*] barbaz0
[*] ...
[*] barbaz9
[*] baz0
[*] ...
[*] baz9
[*] bazfoo0
[*] ...
[*] bazfoo9
[*] bazbar0
[*] ...
[*] bazbar9
[*] bazbaz0
[*] ...
[*] bazbaz9
```
## Install
go get github.com/alixaxel/genex
## License
MIT