tools / developer
Testeur d'expressions régulières
Testez des expressions régulières avec mise en surbrillance en temps réel.
//
CHAÎNE DE TEST
RÉFÉRENCE RAPIDE
.tout caractère sauf retour à la ligne\dchiffre [0-9]\wcaractère de mot [a-zA-Z0-9_]\sespace blanc^début de chaîne/ligne$fin de chaîne/ligne*0 ou plus+1 ou plus?0 ou 1 (facultatif){n,m}entre n et m fois(abc)groupe capturant(?:abc)groupe non capturanta|ba ou b[abc]classe de caractères[^abc]classe niéeÀ PROPOS DE CET OUTIL
Write a regular expression and paste sample text to see matches highlighted in real time as you type. Supports standard flags like global (g), case-insensitive (i), and multiline (m), and shows capture groups separately from the full match so you can see exactly what a pattern extracts versus what it simply matches. A practical way to build, test, and refine patterns before dropping them into code, since regex behavior can vary subtly between languages — JavaScript, Python, and PCRE handle lookbehind, Unicode property escapes, and named groups differently — and testing against real sample text catches edge cases no amount of trial and error in production would.
COMMENT UTILISER
- Type your regular expression pattern into the pattern field.
- Set any flags you need — global to find all matches, case-insensitive to ignore letter case, multiline for ^ and $ to match per line.
- Paste representative sample text into the test area, including edge cases you're worried about.
- Watch matches highlight live as you edit the pattern.
- Inspect capture groups separately from the overall match to confirm what your pattern would extract in code.
- Refine the pattern until it matches everything it should and nothing it shouldn't, then copy it into your codebase.
CAS D'USAGE COURANTS
- A developer writing a form validator builds a pattern to check whether an email or phone number format is valid before submitting.
- Someone parsing log files crafts a regex to extract IP addresses or timestamps from unstructured text.
- A developer doing a find-and-replace across a codebase tests a pattern against sample lines before running it in their editor's regex search.
- A data engineer cleaning a messy CSV writes a pattern to strip unwanted characters or split combined fields.
- Someone debugging why a regex isn't matching in production pastes the exact failing input to see which part of the pattern is the problem.
CONSEILS ET ERREURS COURANTES
- Greedy quantifiers like .* match as much as possible and can overshoot across unexpected text — try the lazy version .*? when you want the shortest possible match instead.
- Regex flavors differ: JavaScript only added lookbehind assertions in newer engines and lacks some PCRE features, so a pattern written for Python's re module may need tweaking to run in JavaScript.
- Special characters like ., *, +, ?, (, ), [, and \ have meaning in regex and must be escaped with a backslash if you want to match them literally.
- Without the global flag, most regex methods stop after the first match — forgetting it is a common reason "it only replaced one instance" bugs happen.
AUTRES QUESTIONS
- Why does my pattern work here but not in my code?
- Regex syntax differs slightly between engines — JavaScript, Python, and PCRE (used by many other languages) handle things like named groups, lookbehind, and Unicode property escapes differently, so always confirm which flavor your target language uses.
- What's the difference between a match and a capture group?
- The match is the entire substring the pattern found; capture groups, created with parentheses, let you pull out specific sub-parts of that match, like extracting just the domain from a matched email address.
- Why does my pattern match too much text?
- Greedy quantifiers (*, +, {n,}) consume as many characters as possible by default; add a ? after the quantifier (like *?) to make it lazy and match the shortest possible string instead.
- Can regex validate something complex like a fully RFC-compliant email address?
- Technically only with an extremely long, hard-to-read pattern — most real-world validators use a simplified regex for basic format checks and rely on actually sending a confirmation email to verify it's real and deliverable.
GUIDES ASSOCIÉS
Tutoriel sur les expressions régulières
Apprenez les expressions régulières depuis zéro avec des exemples pratiques.