Skip to main content

Generate Random Regex

Project description

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))
...

Project details


Download files

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

Source Distribution

random-regex-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file random-regex-1.0.0.tar.gz.

File metadata

  • Download URL: random-regex-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for random-regex-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9c78a105cd69f10b961165a53a6fc468c6c3683989c2f29332d2d386479f923f
MD5 6ce6f34106863a9156b7737fa0133242
BLAKE2b-256 759e97010b9a9416802ff2a166df940bca78bbd5834260a034daf16140ad53cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page