Coding and Data

Generate a Regex from Tests

Run every positive and negative case in the actual regex engine before using the pattern on untrusted input.

Prompt

MetaCyberGuru reviewed
Create a regular expression for [ENGINE] that should match [POSITIVE EXAMPLES] and reject [NEGATIVE EXAMPLES]. Explain anchors, groups and escaping. Prefer the simplest readable pattern. Include executable test cases for the named language or tool, note Unicode or multiline assumptions, and warn about catastrophic backtracking when relevant. If examples conflict, ask for clarification instead of guessing.

What to customize

  • [ENGINE]
  • [POSITIVE EXAMPLES]
  • [NEGATIVE EXAMPLES]

Expected output

A tested, explained regex with engine-specific assumptions and performance cautions.

Check before you rely on it

AI output can be incomplete or wrong. Verify facts, run code, check citations and keep private data out of tools that your organization has not approved.

Related prompts

View the category