Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

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

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/(?m)^([^ ]+) ([^ ]+) (.+?)(?:\s*\.\s)+0,00$/'; $str = 'ABCD COUCOU...... Test0123.................. . . . 0,00 1000 481010582876 PORTE ASS. GR. . . . . . . . . . 0,00 1001 480120101448 CHARNIERE SCREW MINI2. . . . . . 0,00 1170 481949878366 AVM141-Poignée pour plat Crisp . 0,00 1300 480120101791 CAME PLATE. . . . . . . . . . . 0,00 1301 480120101451 LEVIER. . . . . . . . . . . . . 0,00 1302 480120101452 SUPPORT. . . . . . . . . . . . . 0,00 1303 481231038739 INTERRUPTEUR + INTERS . . . . . 0,00 1304 481231038743 PION PORTE. . . . . . . . . . . 0,00 2460 480120101453 PLAT CRISP SMALL. . . . . . . . 0,00 2550 481246678412 PLATEAU TOURN. TOURNANT 25 cm. . 0,00 2640 481010422369 PLATEAU TOURN. CERCHIO MIBI GR/. 0,00 2641 481946238767 RAIL PLAT TOURN. . . . . . . . . 0,00 3010 481010582875 DOSSERET C+ IXL GR Mini2. . . . 0,00 3320 480120100884 POUSSOIR C+1. . . . . . . . . . 0,00 3321 480120100885 POUSSOIR C+2. . . . . . . . . . 0,00 3322 480120100782 POUSSOIR HINGES. . . . . . . . . 0,00 3500 481010364177 AFFICHEUR APRÈS: 46/10. . . . . 0,00 4040 481213158813 MAGNETRON. . . . . . . . . . . . 0,00 4120 480120100336 TRANSFORMATEUR HT. . . . . . . . 0,00 4200 481212158159 CONDENSATEUR. . . . . . . . . . 0,00 4220 481236158419 MOTEUR TT. . . . . . . . . . . . 0,00 4260 481221838323 DIODE AT. . . . . . . . . . . . 0,00 4400 480120101953 MOTEUR. . . . . . . . . . . . . 0,00 4520 480120101407 ELEM. CHAUFFANT 350W 115V. . . . 0,00 4521 481225998463 ROTISSOIRE. . . . . . . . . . . 0,00 4522 480120101247 PROTECTION GRILL. . . . . . . . 0,00 4800 481068977341 LIMANDE AFFICHEUR - PLAT PUISS. 0,00 4900 480120101164 CORDON SECTEUR. . . . . . . . . 0,00 5000 481010577756 PLATINE CONTROLE FREJA2 ACU GR-. 0,00 5610 480120100531 THERMOSTAT 130C. . . . . . . . . 0,00 6330 480120101578 INTERRUPTEUR. . . . . . . . . . 0,00 6520 481213418008 LAMPE. . . . . . . . . . . . . . 0,00 '; $subst = ""; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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