https://github.com/nilium/regen
Tool to generate random strings from Go/RE2 regular expressions (Migrated to https://git.sr.ht/~nilium/regen)
https://github.com/nilium/regen
evil regexp regular-expression string-generator
Last synced: 23 days ago
JSON representation
Tool to generate random strings from Go/RE2 regular expressions (Migrated to https://git.sr.ht/~nilium/regen)
- Host: GitHub
- URL: https://github.com/nilium/regen
- Owner: nilium
- License: bsd-2-clause
- Created: 2016-03-05T03:01:15.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T20:32:40.000Z (over 1 year ago)
- Last Synced: 2025-10-10T13:37:28.823Z (4 months ago)
- Topics: evil, regexp, regular-expression, string-generator
- Language: Go
- Homepage: https://go.spiff.io/regen
- Size: 16.6 KB
- Stars: 79
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
regen
=====
$ go get go.spiff.io/regen
regen is a small tool to generate more or less random strings from Go RE2 regular expressions. You
can read up on RE2 at .
As a few examples:
$ regen -n 2 '0x[\da-f]{16}'
0x8f5858102a5ce124
0x3e4c9fee6c9f419d
$ regen -n 3 '[a-z]{6,12}(\+[a-z]{6,12})?@[a-z]{6,16}(\.[a-z]{2,3}){1,2}'
iprbph+gqastu@regegzqa.msp
abxfcomj@uyzxrgj.kld.pp
vzqdrmiz@ewdhsdzshvvxjk.pi
Essentially, all regen does is parse the regular expressions it's given and iterate over the tree
produced by [regexp/syntax](https://golang.org/pkg/regexp/syntax/) and attempt to generate strings
based on the ops described by its results. This could probably be optimized further by compiling the
resulting Regexp into a Prog, but I didn't feel like this was worthwhile when it's a very small
tool.
Currently, handling word boundaries is not supported and will cause regen to panic in response. The
way line endings and EOT is handled are also likely incorrect and they'll need some more thinking
put into them.
Some additional information can be found at .
Contributing
------------
Development of regen is frozen except for bug fixes since it does what I wanted it to do (for the
most part). My suggestion is to fork it if you have any plans to do more with it, a few others have
done this (e.g., to turn it into a testing package) to continue it in other directions and that's
perfectly fine.
License
-------
regen is licensed under a 2-clause BSD license. This can be found in LICENSE.txt.