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.1.tar.gz (15.5 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.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rector-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 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.1.tar.gz
Algorithm Hash digest
SHA256 cba2b2fa910f42433571c22e81d0a8ce77a9806bc51a0f682144c4fa1feaefa3
MD5 c1ba28eca9fd3037157bd1591568a25a
BLAKE2b-256 8dff0dc053ad0f2ac38a6ac3ffb3d6a66b03e36bf53578bde028e06eb3607925

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rector-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e07e7c20f3c10dd5c5f20aead1bd3da6ea8fbca21d627d557df309b59a0ffaa
MD5 3aaa2893efd4b2167e5f6e5838f57ac1
BLAKE2b-256 e17db0ddd67693438b1a2916852f0fa146c5a523a3b1be362813ca5206977e1d

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