Regex generator prompt: pattern plus explanation
Describe the text pattern you need matched and receive a tested regular expression with a part-by-part explanation.
متى تستخدم هذا البرومبت
- When validating form input like emails or phone numbers.
- When extracting data from log files or text dumps.
- When you can't remember regex syntax for a specific engine.
نص البرومبت
Write a regular expression that matches: {{focus}}. Target language/engine: {{language}}. Include a short explanation of each part of the pattern and one example string it matches and one it rejects.
{{CLIPBOARD}}{{focus}}{{language}}{{CLIPBOARD}}الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».
كيف تستخدمه
- انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
- الصقه في ChatGPT أو Claude أو Gemini.
- عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.
مثال على النتيجة
Pattern: ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$
Explanation:
- ^[\w.+-]+ local part: letters, digits, . + -
- @ literal at sign
- [\w-]+\.[a-zA-Z]{2,}$ domain and TLD
Matches: user.name+tag@example.co
Rejects: user@@exampleنصائح للاستخدام
- Mention the regex flavor (PCRE, JavaScript, POSIX) since escaping rules differ.
- Paste a few real sample strings so the pattern is tuned to your actual data.
- Ask for the non-greedy version if you're matching inside larger text blocks.
النماذج الموصى بها
GPT
أسئلة شائعة
- Will the regex work in any language?
- Regex syntax varies slightly by engine; specify JavaScript, Python, PCRE, etc. so escaping and flags are correct.
- Can it explain a regex I already have instead?
- Yes, paste the pattern into the clipboard field and ask it to explain rather than generate one.