Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
Processing...

Test String

Code Generator

Generated Code

$re = '/(\d{3}\s\d{3}\s\d{3}\s\d{3})\s+(.+?)\s+(\d{2}\/\d{2}\/\d{4})\s+(\d+,\d+)\s+([\d,]+\s[€$£])\s+([\d,]+\s[€$£])\s+(\d+,\d+%)\s+([\d,]+\s[€$£])/m'; $str = 'janvier 2024\\n54 \\n31/01/2024\\nMontant HT TVA Montant TTC\\nTotal TVA 5,50% \\n9 799,13 € \\n5,50% \\n10 338,09 €\\nTotal TVA 20,00% \\n10 973,38 € \\n20,00% \\n13 168,07 €\\nTotal 20 772,51 € 23 506,16 €\\nCode Affaire Désignation Commande Unité Tarif Montant HT TVA Montant TTC\\n117 253 668 000 Pack Colorie et Décore LOL (M01172-1) 31/01/2024 668,000 2,496 € 1 667,33 € 20,00% 2 000,80 €\\n212 153 668 000 Coffret créatif LOL XS (M02121-1) 31/01/2024 265,000 3,329 € 882,19 € 20,00% 1 058,63 €\\n438 653 668 000 Pochette dinosaures (M04386-1) 31/01/2024 225,000 2,079 € 467,78 € 20,00% 561,34 €\\n499 253 668 000 Pochette activités Girly (M04992-1) 31/01/2024 1 028,000 2,839 € 2 918,49 € 5,50% 3 079,01 €\\n499 753 668 000 Mon carnet fantaisie (M04997-1) 31/01/2024 1 459,000 4,716 € 6 880,64 € 5,50% 7 259,08 €\\n503 853 668 000 Coffret créatif Licorne XS (M05038-1) 31/01/2024 991,000 3,329 € 3 299,04 € 20,00% 3 958,85 €\\n504 153 664 000 Coffret créatif Licorne Emoji (M05041-1) 31/01/2024 434,000 4,162 € 1 806,31 € 20,00% 2 167,57 €\\n508 253 668 000 Coffret créatif LOL XL (M05082-1) 31/01/2024 524,000 4,162 € 2 180,89 € 20,00% 2 617,07 €\\n528 353 668 000 Set papeterie LOL (M05283-1) 31/01/2024 99,000 1,663 € 164,64 € 20,00% 197,57 €\\n528 653 668 000 Stylos gel LOL (M05286-1) 31/01/2024 243,000 2,079 € 505,20 € 20,00% 606,24 €\\nFACTURES\\nRelevé de vente à facturer\\nPage 1 de 1'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php