Regex Cheatsheet
Référence regex complète avec motifs, classes de caractères, quantificateurs et plus. Recherchez et copiez facilement les motifs.
Character Classes
.Any character except newlinea.c → abc, aXc\dDigit (0-9)\d{3} → 123\DNon-digit\D+ → abc\wWord character (a-z, A-Z, 0-9, _)\w+ → hello_123\WNon-word character\W → @, #, !\sWhitespace (space, tab, newline)a\sb → a b\SNon-whitespace\S+ → hello[abc]Any of a, b, or c[aeiou] → vowels[^abc]Not a, b, or c[^0-9] → non-digits[a-z]Range a to z[A-Za-z] → lettersAnchors
^Start of string/line^Hello → Hello...$End of string/lineworld$ → ...world\bWord boundary\bcat\b → cat (not cats)\BNon-word boundary\Bcat → bobcatQuantifiers
*0 or morea* → '', a, aa, aaa+1 or morea+ → a, aa, aaa?0 or 1 (optional)colou?r → color, colour{n}Exactly n times\d{4} → 2024{n,}n or more times\d{2,} → 12, 123, 1234{n,m}Between n and m times\d{2,4} → 12, 123, 1234*?0 or more (lazy)a*? → minimal match+?1 or more (lazy)<.+?> → <b> (not <b>...</b>)Groups & References
(abc)Capturing group(\d+) → captures digits(?:abc)Non-capturing group(?:ab)+ → abab(?<name>abc)Named capturing group(?<year>\d{4})\1Backreference to group 1(\w)\1 → aa, bb(a|b)Alternation (a or b)(cat|dog) → cat or dogLookahead & Lookbehind
(?=abc)Positive lookahead\d(?=px) → 5 in '5px'(?!abc)Negative lookahead\d(?!px) → 5 in '5em'(?<=abc)Positive lookbehind(?<=\$)\d+ → 100 in '$100'(?<!abc)Negative lookbehind(?<!\$)\d+ → 100 in '€100'Flags
gGlobal (find all matches)/a/g → all 'a' matchesiCase insensitive/abc/i → ABC, abc, AbcmMultiline (^ and $ match line breaks)/^line/msDotall (. matches newlines)/a.b/s → a\nbuUnicode support/\u{1F600}/u → emojiCommon Patterns
^[\w.-]+@[\w.-]+\.\w{2,}$Email (basic)user@example.com^https?://[\w.-]+(?:/[\w.-]*)*$URL (basic)https://example.com/path^\d{4}-\d{2}-\d{2}$Date (YYYY-MM-DD)2024-01-15^\+?[\d\s-]{10,}$Phone number (basic)+1 555-123-4567^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$Hex color#FF5733, #F00^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$IPv4 address (basic)192.168.1.1Expressions Régulières - Détails techniques
Les expressions régulières (regex) sont des motifs pour correspondre au texte. Elles sont utilisées dans la recherche, la validation, l'analyse et la manipulation de texte dans les langages de programmation et les outils.
Alternative en ligne de commande
// Common patterns\n\\d+ Match digits\n\\w+ Match word chars\n^...$ Start/end anchors\n(a|b) Alternation\n(?=...) Positive lookahead