regex_generator
Generate Random Regex
Install
pip install random-regex
Usage
import re
from random_regex import RegexGenerator
from rbloom import Bloom # This is a faster bloom filter implemented in rust.s
regex_generator = RegexGenerator(bloom_cls=Bloom).generate()
def assert_all_match(examples, regex):
re_com = re.compile(regex)
for ex in examples:
assert re_com.fullmatch(ex) is not None
for i, instance in enumerate(regex_generator):
if i > 1000:
break
regex = instance['regex']
complexity = instance['complexity']
length = instance['length']
examples = instance['examples']
re.compile(regex)
assert len(regex) == length
assert len(examples) == complexity
assert_all_match(examples, regex)
print(regex)
((?:(([\s]C\s))))
((\sR2{1,3}\+[m]))
((3{1}[\(-y]a\[))
((\d{1,1}[^08]1A))
(([3-c]))
(([^Rp][CJ]f))
(((G[/]){4,7}))
((.))
(((?:(D2[Qh]))?))
(((!\s)){3})
(([9d])([9d]))
((\s))((\s))
((\d))
((a\s)(a\s)(a\s))
...
Metadata
Release files for random-regex 1.0.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 |
|---|---|---|---|---|
| random-regex-1.0.0.tar.gz | 7.5 kB | Without provenance | Details for random-regex-1.0.0.tar.gz |
Release files / random-regex-1.0.0.tar.gz
| Download URL | random-regex-1.0.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c78a105cd69f10b961165a53a6fc468c6c3683989c2f29332d2d386479f923f
|
|
BLAKE2b-256 checksum How to use checksums |
759e97010b9a9416802ff2a166df940bca78bbd5834260a034daf16140ad53cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for random-regex 1.0.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.