Generate Precise Regular Expressions with AI
This prompt generates precise and documented regular expressions, tailored to your programming language, with detailed explanations and built-in tests.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un expert en expressions régulières (regex). Je travaille avec le langage [LANGAGE_DE_PROGRAMMATION] et j'ai besoin d'une regex pour le cas suivant :
Objectif : [DESCRIPTION_DU_PATTERN_A_CAPTURER]
Exemples de chaînes qui doivent matcher :
- [EXEMPLE_VALIDE_1]
- [EXEMPLE_VALIDE_2]
Exemples de chaînes qui ne doivent PAS matcher :
- [EXEMPLE_INVALIDE_1]
- [EXEMPLE_INVALIDE_2]
Pour chaque regex que tu proposes, fournis :
- La regex complète prête à l'emploi dans [LANGAGE_DE_PROGRAMMATION]
- Une explication segment par segment de chaque partie de la regex
- Un tableau de tests montrant le résultat (match/no match) pour chaque exemple
- Les cas limites potentiels auxquels faire attention
- Une version simplifiée si la regex est complexe, en expliquant les compromis
- Un snippet de code fonctionnel dans [LANGAGE_DE_PROGRAMMATION] utilisant cette regex pour valider ou extraire les données
Personalize this prompt with Léa
Answer 3 questions and Léa tailors the prompt to your situation.
Why this prompt works
<p>This prompt is designed to produce reliable and understandable regular expressions. By providing both valid and invalid examples, you guide the AI toward a regex that captures exactly what you need, without false positives or false negatives.</p><p>The key to a good result lies in the <strong>precision of your description</strong>. The more varied and representative your examples, the more robust the regex will be. Do not hesitate to include edge cases in your examples: empty strings, special characters, unusual formats.</p><p><strong>Advanced tip</strong>: if your need is complex, first ask for a simple version covering 90% of cases, then refine progressively. Also specify whether performance matters (some regex with lookbehind or backtracking can be costly on large volumes of text).</p>
Use Cases
Expected Output
A complete regular expression with a segment-by-segment explanation, a test table validating the provided examples, edge case identification, and a ready-to-use code snippet in the chosen language.
Learn more
Check the full skill on Prompt Guide to master this technique from A to Z.
View on Prompt GuideComments
Be the first to comment on this prompt.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Similar Prompts
Create a Complete REST API from A to Z
A complete prompt to generate a professional REST API with authentication, validation, documentation, and integrated tests.
Set Up Application Observability
Implement the three pillars of observability (logs, metrics, traces) with OpenTelemetry, Prometheus, and Grafana dashboards.
Set up vulnerability scanning pipeline
Automate vulnerability scanning
Perplexity Prompt for Generating SQL Queries
Perplexity stands out from traditional search engines by its ability to synthesize technical information from multiple reliable sources. For generating SQL queries, this tool becomes a true development assistant: it can analyze your database schema, understand your business intent, and produce optimized queries based on the official documentation of PostgreSQL, MySQL, or SQL Server. Unlike a simple code generator, Perplexity contextualizes its responses by citing best practices from Stack Overflow, official documentation, and reputable technical blogs. Whether you need a complex join, an aggregation query with windowing, or performance optimization via indexes, Perplexity provides not only the query but also an explanation of each clause. This educational approach makes it a particularly suitable tool for developers who want to improve their SQL skills while delivering production-ready code. The major advantage lies in its ability to consider the specifics of your DBMS and propose alternatives based on available versions.