Prompt Library 💻 Coding & Dev Write a Regex Pattern
Any 💻 Coding & Dev Basic

Write a Regex Pattern

Generate and explain regular expressions for any matching task.
👁 6 views ⎘ 0 copies ♥ 0 likes

The Prompt

Write a regular expression (regex) that matches the following:

What I need to match: [describe — e.g. all UK phone numbers / email addresses / dates in DD/MM/YYYY format]
Language/flavour: [JavaScript / Python / PHP / PCRE / other]
Edge cases to handle: [list any — e.g. with or without country code, with spaces or dashes]

Provide:
1. The regex pattern
2. A plain-English explanation of what each part does
3. 5 example strings it should match
4. 3 example strings it should NOT match
5. A code snippet showing how to use it in [LANGUAGE]

📝 Fill in the blanks

Replace these placeholders with your own content:

[describe — e.g. all UK phone numbers / email addresses / dates in DD/MM/YYYY format]
[JavaScript / Python / PHP / PCRE / other]
[list any — e.g. with or without country code, with spaces or dashes]
[LANGUAGE]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into Any

Open your preferred AI assistant and paste the prompt to get started.