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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| randre-0.1.0.tar.gz | 3.0 kB | Without provenance | Details for randre-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| randre-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for randre-0.1.0-py3-none-any.whl |
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 |
Security for randre 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.