Skip to main content

Generate random text from regular expression patterns

Project description

PyPI Build Status


Generate random text from regular expression patterns

What is this?

This is a Python module that exploits the internals of Python re module generate random text that matches a given regular expression pattern. I made this mostly for fun. Most patterns will work, but feel free to send feedback if you need something better. Contributions are welcome.


>>> randre(r'a[bc]+a')
>>> randre(r'a[bc]+a')
>>> randre(r'a[bc]+a')
>>> randre(r'a([a-z]{1,3})\1')
>>> randre(r'a([a-z]{1,3})\1')
>>> randre(r'INTERNALDATE "'
...         r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
...         r'(?P<year>[0-9][0-9][0-9][0-9])'
...         r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
...         r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
...         r'"')
'INTERNALDATE "36-Wap-0255 18:61:83 +0201"'

Command line usage

$ python -m randre "(foo|bar)+"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for randre, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size randre-0.1.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View
Filename, size randre-0.1.0-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page