faker
https://github.com/stympy/faker
Ruby
A library for generating fake data such as names, addresses, and phone numbers.
Faker::Base.regexify
Given a regular expression, attempt to generate a string
that would match it. This is a rather simple implementation,
so don't be shocked if it blows up on you in a spectacular fashion.
It does not handle ., *, unbounded ranges such as {1,},
extensions such as (?=), character classes, some abbreviations
for character classes, and nested parentheses.
I told you it was simple. :) It's also probably dog-slow,
so you shouldn't use it.
It will take a regex like this:
/^[A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}$/
and generate a string like this:
"U3V 3TP"Edit
git clone [email protected]:stympy/faker.git
cd faker
open lib/faker.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Faker--Base-regexify-for-pr
# Commit to gitgit add lib/faker.rbgit commit -m "better docs for Faker::Base.regexify"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Faker--Base-regexify-for-pr
hub pull-request
# Celebrate!