Skip to main content

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)

Source distribution for random-regex 1.0.0
File Size Uploaded
random-regex-1.0.0.tar.gz 7.5 kB Details

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

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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