Skip to content
PromptLab by FEHMER TECH
ENDE
Coding

Generate Regex Patterns

Create regular expressions with clear explanations for complex text patterns.

Prompt template

Create a regular expression for the following use case:

**Pattern to match:** [PATTERN DESCRIPTION]
**Programming language/engine:** [LANGUAGE: JavaScript, Python, Java, etc.]
**Examples of valid matches:**
- [EXAMPLE 1]
- [EXAMPLE 2]
- [EXAMPLE 3]

**Examples of invalid strings (should NOT match):**
- [COUNTER EXAMPLE 1]
- [COUNTER EXAMPLE 2]

**Please provide:**
1. **The Regex:** The complete regular expression
2. **Explanation:** Break down the regex into its components and explain each part
3. **Visualization:** Describe the pattern in plain language
4. **Test Cases:** Additional test cases for verification
5. **Variants:** If useful, a stricter and a more lenient version
6. **Performance Note:** Are there potential backtracking issues?

**Flags:** Specify required flags (global, case-insensitive, multiline).

Replace placeholders in [square brackets]: [PATTERN DESCRIPTION][LANGUAGE: JavaScript, Python, Java, etc.][EXAMPLE 1][EXAMPLE 2][EXAMPLE 3][COUNTER EXAMPLE 1][COUNTER EXAMPLE 2]

How to use this template

Copy the prompt, replace the placeholders in square brackets with your details and paste it into the AI assistant of your choice. The more precise your details, the better the result.

Tips for better results

  • Always provide concrete examples of valid and invalid strings
  • Name the regex engine, as syntax can differ
  • Ask for named capture groups for better readability
  • Request performance optimization for large datasets

Suitable open models

The selection names current open models as a starting point for your own tests. It is not a measurement for this template.

Keywords: #regex #pattern-matching #text-processing #validation

Last updated: