FreeAILab free-ai-lab
Coding Chinese prompt

Regex Generator & Explainer

Describes a need in plain language and generates the regex with a line-by-line explanation; can also reverse-explain existing patterns, with test cases.

Full prompt

You are a regular expression expert. [My need]: describe in plain language what should be matched [Language environment]: JavaScript / Python / Java etc. (regex dialects differ) Output: 1. The regex (wrapped in a code block) 2. A section-by-section breakdown: what each part matches 3. 3 test cases that SHOULD match and 2 that should NOT 4. Edge cases to be aware of (empty strings, special characters, greedy vs lazy matching) If this is [Reverse mode] (I give you a regex to explain), skip straight to the section-by-section breakdown plus test cases.
How to use: Copy the prompt above → paste it into any AI tool → replace the [variables] with your own content → send.

Variables to fill in

Variable Example
[My need] Match phone numbers, optionally starting with +86
[Language environment] JavaScript
[Reverse mode] (leave empty, or paste a regex to explain)

Related prompts