P
💻DeveloppementIntermediateAll AIs

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 :

  1. La regex complète prête à l'emploi dans [LANGAGE_DE_PROGRAMMATION]
  2. Une explication segment par segment de chaque partie de la regex
  3. Un tableau de tests montrant le résultat (match/no match) pour chaque exemple
  4. Les cas limites potentiels auxquels faire attention
  5. Une version simplifiée si la regex est complexe, en expliquant les compromis
  6. 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

Validate data formats (emails, phone numbers, postal codes, IBAN)Extract structured information from raw text or logsParse and clean CSV files or poorly formatted API responsesCreate validation rules for web forms

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.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Pour des regex complexes, ajoutez des cas limites directement dans le prompt (ex: chaînes vides, caractères spéciaux). Cela réduit les itérations et affine la précision des motifs proposés par l’IA.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateGemini

Gemini Prompt for Generating SQL Queries

Gemini, Google's artificial intelligence model, excels at generating SQL queries through its deep understanding of data structures and database syntax. Whether you are working with MySQL, PostgreSQL, SQL Server or SQLite, Gemini can transform your natural language descriptions into optimized and functional SQL queries. This capability is particularly valuable for developers looking to speed up their workflow, data analysts handling complex datasets, and beginners learning SQL. By providing a well-structured prompt to Gemini, you not only get the desired query but also explanations of the logic used, optimization suggestions, and alternatives based on your database management system. The prompt engineering approach allows you to guide Gemini to take into account your specific constraints: performance, readability, compatibility with a particular DBMS, or adherence to your organization's naming conventions. Discover how to formulate your prompts to get the most out of Gemini in generating SQL queries.

0146
💻DeveloppementAdvancedAll AIs

Create Async Workers and Jobs with AI

A complete prompt to design and implement async workers and jobs with queuing, retry, monitoring and deployment.

057
💻DeveloppementBeginnerChatGPT

Install and Configure PostgreSQL for a Project

Install and configure PostgreSQL from scratch with database creation, users, application connection, and first SQL queries.

14328
💻DeveloppementAdvancedAll AIs

Prompt to Create Optimized Serverless Functions

A complete prompt to design production-ready serverless functions on Vercel or AWS Lambda, covering code, security, performance and deployment.

00