Skip to main content

Regex generator that derives optimized patterns from example strings.

Project description

rector — Regex Generator

Rector generates optimized regular expressions from example strings, so you can quickly derive a compact pattern that matches your data. It follows the standard src/ layout, ships with a pyproject.toml, and is ready to publish to PyPI.

Features

  • Generate a regex from multiple example strings with sensible character-class generalization
  • Anchored patterns by default, with optional flags
  • PyPI-ready packaging via hatchling and PEP 621 metadata
  • BDD-ready pytest configuration plus a sample pytest-bdd feature
  • src/ layout with type hints and minimal dependencies

Installation

pip install rector

For development (editable install plus tooling):

pip install -e .'[dev]'

Usage

from rector import RegexGenerator

generator = RegexGenerator()
pattern = generator.generate(["2025-11-28", "2024-01-01", "1999-12-31"])

assert pattern.fullmatch("2025-11-28")
assert not pattern.fullmatch("28/11/2025")

Development

  • Run tests: pytest
  • Focus on BDD scenarios: pytest tests/features
  • Build a distribution: pip install hatchling && hatch build

Project layout

  • pyproject.toml — packaging metadata and pytest config
  • src/rector/ — package code
  • tests/features/.feature files for BDD scenarios
  • tests/steps/ — step definitions exercised by pytest-bdd

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

rector-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rector-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file rector-0.1.0.tar.gz.

File metadata

  • Download URL: rector-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78110b3e7ad0ba0e7411a897b1978214a91027594d0613bb5ef202eb769bae69
MD5 99ee60d63cd4d080022c5708bb951d3b
BLAKE2b-256 7a7f219dc4f1aee9ba9026c4053521d289715de0ae5cd5113fd71e12569a9fc8

See more details on using hashes here.

File details

Details for the file rector-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rector-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42766bf20bd3aa16d28db9ae7b67ec52de074563821fbd01d5db529e8fffe315
MD5 2dfcb0256985b1037cb4fa87ee3cc9bb
BLAKE2b-256 6a5f6fd1e46ab5962a8414c9b536ce76caf3c5f2ed0b012548ad660cde5637bb

See more details on using hashes here.

Supported by

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