regex-builder
by official
Build, explain, or convert regular expressions: describe what you want to match in plain English to generate a working regex with breakdown and test cases, explain an existing regex pattern, or convert between regex and natural language descriptions
# regex-builder
Build or explain regular expressions: describe what you want to match in plain English to generate a working regex with breakdown and test cases, or explain an existing regex pattern.
**Category:** Developer
## Installation
This is a CmdForge tool. Install it from the registry:
```bash
cmdforge install regex-builder
```
## Usage
### Building a regex from a description
Describe what you want to match in plain English:
```bash
echo "match email addresses" | regex-builder
```
```bash
echo "find all dates in MM/DD/YYYY format" | regex-builder
```
```bash
echo "extract phone numbers with optional country code" | regex-builder
```
### Explaining an existing regex
Use the `--explain` flag to understand what a regex pattern does:
```bash
echo "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" | regex-builder --explain
```
```bash
echo "\b\d{3}-\d{2}-\d{4}\b" | regex-builder --explain
```
```bash
echo "(?:https?://)?(?:www\.)?[\w\-]+\.[\w\-]+(?:/[\w\-._~:/?#[\]@!$&'()*+,;=]*)?" | regex-builder --explain
```
## Arguments
| Flag | Default | Description |
|------|---------|-------------|
| `--explain` | `false` | Explain an existing regex instead of building one |
## How It Works
1. **Mode Detection** - Determines whether to build a new regex or explain an existing pattern based on the `--explain` flag
2. **Generate or Explain** - Uses Claude Sonnet to either:
- Generate a working regex pattern from your description with breakdown and test cases
- Explain an existing regex pattern in plain English with component breakdown
The tool provides comprehensive output including pattern explanations, capture groups, and example test cases to verify the regex works as expected.
## Dependencies
None
Reviews
Login to reviewNo reviews yet.
Issues
No issues reported for this tool.
Write a Review
Share your experience with this tool.
0/2000
Report an Issue
Help improve this tool by reporting bugs or security issues.