Regex Humanizer CLI

A CLI tool that converts complex regex patterns to human-readable English descriptions and generates comprehensive test cases.

Features

  • Regex to English Translation: Convert any regex pattern to plain English
  • Test Case Generation: Auto-generate matching and non-matching test inputs
  • Multi-Flavor Support: Supports PCRE, JavaScript, and Python regex flavors
  • Interactive Mode: REPL-style interface for exploring regex patterns
  • Pattern Validation: Validate regex patterns for different flavors
  • Flavor Conversion: Convert patterns between different regex flavors

Installation

pip install regex-humanizer-cli

Or from source:

pip install -e .

Quick Start

Explain a regex pattern

regex-humanizer explain "^\d{3}-\d{4}$"

Output:

Pattern: ^\d{3}-\d{4}$
Flavor: pcre

English Explanation:
--------------------------------------------------
at the start of line or stringany digit (0-9)any digit (0-9)any digit (0-9)hyphenany digit (0-9)any digit (0-9)any digit (0-9)any digit (0-9)at the end of line or string

Generate test cases

regex-humanizer test "^[a-z]+$"

Output:

Pattern: ^[a-z]+$
Flavor: pcre

Matching strings (should match the pattern):
--------------------------------------------------
  1. abc
  2. hello
  3. world

Non-matching strings (should NOT match the pattern):
--------------------------------------------------
  1. 123
  2. Hello
  3. test123

Interactive mode

regex-humanizer interactive

Commands

explain

Explain a regex pattern in human-readable English:

regex-humanizer explain "PATTERN" [OPTIONS]

Options:

  • --output, -o: Output format (text/json, default: text)
  • --verbose, -v: Show detailed breakdown
  • --flavor, -f: Regex flavor (pcre/javascript/python)

test

Generate test cases for a regex pattern:

regex-humanizer test "PATTERN" [OPTIONS]

Options:

  • --output, -o: Output format (text/json, default: text)
  • --count, -n: Number of test cases (default: 5)

interactive

Start an interactive REPL for exploring regex patterns:

regex-humanizer interactive [OPTIONS]

Options:

  • --flavor, -f: Default regex flavor

flavors

List available regex flavors:

regex-humanizer flavors

validate

Validate a regex pattern:

regex-humanizer validate "PATTERN" [OPTIONS]

Options:

  • --flavor, -f: Specific flavor to validate against

convert

Convert a regex pattern between flavors:

regex-humanizer convert "PATTERN" --from-flavor pcre --to-flavor javascript

Flavor Support

Feature PCRE JavaScript Python
Lookahead
Lookbehind ⚠️ Limited
Named Groups
Possessive Quantifiers
Atomic Groups

Configuration

No configuration file required. All options can be passed via command line.

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run linting
ruff check regex_humanizer/

# Run type checking
mypy regex_humanizer/ --ignore-missing-imports

License

MIT License

Description
A CLI tool that parses OpenAPI/Swagger specs and automatically generates integration test templates with mock servers
Readme MIT 161 KiB
v0.1.0 Latest
2026-02-06 04:53:25 +00:00
Languages
Python 89.3%
Jinja 10.7%