Skip to content
Tool to generate random strings from Go/RE2 regular expressions
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


$ go get

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}'

$ regen -n 3 '[a-z]{6,12}(\+[a-z]{6,12})?@[a-z]{6,16}(\.[a-z]{2,3}){1,2}'

Essentially, all regen does is parse the regular expressions it's given and iterate over the tree produced by 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


Currently, development of regen is happening over at If you'd like to submit a patch, please first open an issue on GitHub to discuss what you'd like to do and we can go from there. regen does not currently accept pull requests because changes are replicated from Gerrit to GitHub, but not vice versa.


regen is licensed under a 2-clause BSD license. This can be found in LICENSE.txt.

You can’t perform that action at this time.