AI Prompts Library

Curated collection of expert prompts for coding, writing, marketing, image generation, and more

Have a great prompt? Submit it to the library →

Coding

Regex Pattern Builder and Explainer

Optimized for: general • TEXT
You are a regex expert who creates, explains, and debugs regular expressions. Help with the described pattern matching need.

**What to Match:** [DESCRIBE WHAT YOU WANT TO MATCH]
**Programming Language:** [JavaScript / Python / Go / Java / PHP / Ruby / .NET]
**Sample Input:** [PROVIDE SAMPLE STRINGS THAT SHOULD AND SHOULD NOT MATCH]

**Provide:**

1. **The Regex Pattern:**
   - Provide the complete pattern with proper delimiters for the language
   - Include necessary flags (global, case-insensitive, multiline)
   - If the pattern has capture groups, explain what each group captures

2. **Visual Breakdown:**
   - Break the regex into segments
   - Explain each segment in plain English
   - Use a character-by-character walkthrough for complex parts
   - Show the pattern as a railroad diagram description

3. **Test Cases:**
   - 5 strings that SHOULD match (with explanation of what is captured)
   - 5 strings that should NOT match (with explanation of why)
   - Edge cases to be aware of

4. **Usage Example:**
   - Complete code snippet showing the regex in use
   - Include: matching, extracting groups, replacing, and splitting examples
   - Show how to handle the match result properly

5. **Performance Notes:**
   - Warn about catastrophic backtracking risks
   - Suggest non-capturing groups where capture is not needed
   - Recommend possessive quantifiers or atomic groups if supported
   - Alternative approach if regex is not the best tool for this job

6. **Common Variations:**
   - Provide a stricter version that rejects more edge cases
   - Provide a more lenient version that accepts more formats
   - Show how to make the pattern Unicode-aware if relevant

**Output**: The regex pattern, visual explanation, test cases, and ready-to-use code snippet.

Input validation, text parsing, data extraction, log analysis, search and replace

Coding

Regex Pattern Generator & Explainer

Optimized for: general • TEXT
Create and explain regular expression patterns.

**Task**: [DESCRIBE WHAT YOU WANT TO MATCH]

**Examples of valid inputs:**
- [EXAMPLE 1]
- [EXAMPLE 2]

**Examples of invalid inputs:**
- [EXAMPLE 1]
- [EXAMPLE 2]

**Generate:**

1. **Regex Pattern**
```
/pattern/flags
```

2. **Explanation** (step-by-step breakdown)
- `^` - Start of string
- `[a-z]` - Lowercase letter
- etc.

3. **Flags Explained**
- `g` - Global match
- `i` - Case insensitive
- `m` - Multiline

4. **Test Cases**
```
Should match:
✓ "example1"
✓ "example2"

Should not match:
✗ "invalid1"
✗ "invalid2"
```

5. **Code Examples**
- JavaScript
- Python
- PHP

6. **Performance Tips**
- Optimization suggestions
- Common pitfalls
- Alternative approaches

Input validation, data parsing, text processing

Want Custom Prompts?

Get personalized AI prompts tailored to your specific needs and workflow.

Contact Us