Skip to main content

PyPI Build Status

randre

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.

Usage

>>> randre(r'a[bc]+a')
'accbbccbbcccbcccbbbbcccccbbbccbcbbbbbbbcccbcbbccbcbbcbbbcbbccccbcbbccbbccba'
>>> randre(r'a[bc]+a')
'abbcbcbbbbbccbcbcccbbcbcbbccbcbcbcbbccca'
>>> randre(r'a[bc]+a')
'abbcbcbbbbcccbccba'
>>> randre(r'a([a-z]{1,3})\1')
'aufuf'
>>> randre(r'a([a-z]{1,3})\1')
'assussu'
>>> 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)+"
barbarfoofoofoobarfoofoobarbarbarbarbarbarfoobarfoofoofoofoofoobarfoobarfoobarfoofoobarbarbarbarfoobarbarbarbarfoobarfoofoofoobarbarbarfoofoofoofoofoofoobarbarfoofoobarbarbarbarfoofoobarbarbarbarfoobarbarfoobarbarbarfoobarbarfoofoofoofoofoobarbarbarbarbarfoobarbarbar

Metadata

Release files for randre 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for randre 0.1.0
File Size Uploaded
randre-0.1.0.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for randre 0.1.0
File Interpreter ABI Platform
randre-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / randre-0.1.0.tar.gz

Download URL randre-0.1.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d3d56ea7a1a746eddda77fd66affd77f210d3c335c99f41f6f6c8397b1c6ebdd
BLAKE2b-256 checksum
How to use checksums
6847871a1f3240adc960440569f8032038cfc68a782111be9c1b0cf0ee608fc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / randre-0.1.0-py3-none-any.whl

Download URL randre-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00a29a419b524dd185435b50ebbd93933426e8f2326b72bed9cdb8ef015db05e
BLAKE2b-256 checksum
How to use checksums
4b08f3b087da6fee360d366b4d07fddfcd83878281b08964f48cdcacf332d1d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page