Files
api-testgen-cli/README.md
CI Bot 52e792305b feat: initial commit for regex-humanizer-cli
- Add regex parser, translator, and test generator
- Add CLI with explain, test, interactive commands
- Add multi-flavor support (PCRE, JavaScript, Python)
- Add Gitea Actions CI workflow
- Add comprehensive README documentation
2026-02-06 03:02:57 +00:00

172 lines
3.2 KiB
Markdown

# 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
```bash
pip install regex-humanizer-cli
```
Or from source:
```bash
pip install -e .
```
## Quick Start
### Explain a regex pattern
```bash
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
```bash
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
```bash
regex-humanizer interactive
```
## Commands
### explain
Explain a regex pattern in human-readable English:
```bash
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:
```bash
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:
```bash
regex-humanizer interactive [OPTIONS]
```
Options:
- `--flavor, -f`: Default regex flavor
### flavors
List available regex flavors:
```bash
regex-humanizer flavors
```
### validate
Validate a regex pattern:
```bash
regex-humanizer validate "PATTERN" [OPTIONS]
```
Options:
- `--flavor, -f`: Specific flavor to validate against
### convert
Convert a regex pattern between flavors:
```bash
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
```bash
# 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