EN
My account

Your privacy, your call. No advertising cookies. May we count your visit in aggregate (Cloudflare, no cookies) and remember where you came from? If you reject, we won’t measure your visit. · Cookies · Privacy

Privacy settings

Choose what we measure and what we keep in this browser. We never sell or share your data.

Essential

Remember your theme, language, saved items and this choice. Without them the site cannot work the way you ask.

Always on

Keeps the source of your first and latest visit for 90 days (utm parameters and referring site). It only leaves your browser if you subscribe to the newsletter.

Cloudflare Web Analytics counts visits in aggregate: page, referring site, country, browser and load times. No cookies, no identifiers and no profiling; nothing is stored in your browser. It only loads if you accept it. If you reject it or switch it off, it does not load (or stops loading from the next page) and we do not count your Telegram clicks either.

Cookies · Privacy

Work · Professional prompt

Regular expression explained

Professional structure: role, context, objective, details, steps, format, criteria and self-check. Designed for better results, not guaranteed ones: always review the answer.

Never use real personal data. If you need to, run it through the data cleaner.

Fill in the blanks
## Role
Act as a programmer who is an expert in regular expressions.

## Context
I need to validate or find a text pattern and regular expressions confuse me.

## Objective
Get a correct, explained and tested regular expression.

## Details (fill in what is in square brackets)
- [what I want to find or validate]
- [language or tool where I will use it]
- [examples that should and should not match]

## Step-by-step instructions
1. Write the regular expression.
2. Explain each part in a table.
3. Test the expression against the examples given.
4. Warn about cases it does not cover.

## Output format
Regex in a code block, explanation table, test table and limitations.

## Quality criteria
- It works in the stated language.
- It avoids patterns that could be very slow.
- It is no more complex than needed.

## Self-check
Before answering, check every quality criterion. If information is missing, ask me instead of making it up, and at the end state what you have assumed.

The link opens the empty template: what you type is not included.

Objective

Get a correct, explained and tested regular expression.

When to use it

This prompt is brilliant when you are wrestling with complex string matching, data validation, or text extraction tasks where logic feels opaque. It shines when you need a robust, readable solution for form inputs, log parsing, or data cleaning. However, it is less useful for highly non-regular languages or complex parsing tasks like full HTML extraction or nested structures. Avoid relying on regex for deeply recursive patterns, as a proper parser or library is always the better choice for those complex requirements.

Worked example: input (fictional data)

What I want to find or validate: I need a regex to match UK mobile phone numbers that start with 07 and have 11 digits total. They might have spaces or hyphens between the groups. Language or tool where I will use it: JavaScript. Examples that should and should not match: Should match: 07123 456789, 07987-654-321, 07700900123. Should not match: 0800 123 456, 77123 456789, 07123 45678, 07123 45678901.

Worked example: full response

The regular expression: ^07\d{1}(\s|-)?\d{3}(\s|-)?\d{6}$ Explanation of parts: - ^: Asserts the start of the string. - 07: Matches the literal characters 07. - \d{1}: Matches exactly one digit. - (\s|-)?: An optional group matching a space or hyphen. - \d{3}: Matches exactly three digits. - (\s|-)?: Another optional group for a separator. - \d{6}: Matches the final six digits. - $: Asserts the end of the string. Testing against examples: - 07123 456789: Matches successfully. - 07987-654-321: Matches successfully. - 07700900123: Matches successfully. - 0800 123 456: Fails, does not start with 07. - 77123 456789: Fails, missing the leading 0. - 07123 45678: Fails, too short. - 07123 45678901: Fails, too long. Limitations to consider: This pattern assumes a standard 11-digit structure for UK mobile numbers. It does not account for international prefixes like +44 or 0044. If you need to support those, you will need a significantly more complex expression that handles the country code variations and potential leading zeros differently. This regex is strictly for local-format numbers starting with 07.

Variants

Quick and dirty

Provide only the regex pattern and a brief one-sentence confirmation that it works as requested. Skip the table explanation, the detailed testing, and the limitations section. I just need a clean, copy-pasteable solution immediately for my script.

For absolute beginners

Explain the regex as if I have never seen one before. Use simple analogies for each part, avoiding overly technical jargon. Ensure the explanation breaks down the logic step-by-step so I can learn how to modify it myself later if my requirements change slightly.

Performance focused

Prioritise efficiency. Provide the regex, but specifically ensure it avoids catastrophic backtracking or inefficient quantifiers. Explain why your chosen approach is performant for large datasets or high-frequency processing, and highlight any potential bottlenecks I should watch out for when running this against massive text files.

Common mistakes

Related guide

General and assistant-specific tips

Getting the most out of it

  • Paste the prompt as is and only replace what is in [brackets].
  • If the answer does not fit, do not start over: ask for “shorter”, “more formal” or “as a table”.
  • Always review the result before using it: AI can get facts, dates or names wrong.

Before you paste it: quick checklist

  • Remove client names, amounts and internal data before pasting.
  • Say who the text is for and which tone you want.
  • Ask for a specific length: “120 words max” or “three bullet points”.
  • Read the result aloud and fix anything you wouldn’t say yourself.

How to adapt it to your assistant

The template works the same in ChatGPT, Gemini, Copilot or Claude because it only uses plain language. If your assistant supports fixed instructions (custom instructions, Gems or projects), you can store your preferred tone and format there and paste only the variable part. On a free plan, split long requests into two or three shorter messages.

See all Work prompts

More professional prompts

← All prompts

Found this prompt useful? A new one every Tuesday

Every Tuesday, 5 minutes: AI news with sources, a tool with its prompt and a guide. Free, with one-click unsubscribe. What is inside and a sample issue