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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/([0-9]+)(\.)([0-9]{2})([0-9]+)/m'; $str = 'Direzione,Gennaio % di presenza,Gennaio % di assenza,Febbraio % di presenza,Febbraio % di assenza,Marzo % di presenza,Marzo % di assenza,Aprile % di presenza,Aprile % di assenza,Maggio % di presenza,Maggio % di assenza,Giugno % di presenza,Giugno % di assenza Segretario Generale,79.5652173913,20.4347826087,86.5,13.5,88.1818181818,11.8181818182,83.6842105263,16.3157894737,,,, "Direzione Pianificazione Strategica e Politiche Comunitarie",72.9537366548,27.0462633452,72.65625,27.34375,74.8251748252,25.1748251748,75.3036437247,24.6963562753,,,, Corpo Polizia Metropolitana,81.6598360656,18.3401639344,83.837273227,16.162726773,88.0701754386,11.9298245614,82.9337899543,17.0662100457,,,, Ufficio del Direttore Generale,90.1515151515,9.84848484848,91.4285714286,8.57142857143,85.0649350649,14.9350649351,83.4586466165,16.5413533835,,,, "Direzione Gare e Contratti dell\'Ente, Espropri, SUA",73.2057416268,26.7942583732,78.1578947368,21.8421052632,82.5358851675,17.4641148325,79.5013850416,20.4986149584,,,, "Direzione Supporto Organi Istituzionali, Sindaco, Consiglio e Conf. Metr., AA. GG. Flussi Doc., Anticor., Trasp., Controlli + CdG.",80.5755395683,19.4244604317,82.1240105541,17.8759894459,81.0538780343,18.9461219657,81.4128943759,18.5871056241,,,, "Direzione Politiche del Personale, Pari Opportunità, Qualità dei Servizi",71.1538461538,28.8461538462,77.5,22.5,83.9160839161,16.0839160839,76.0233918129,23.9766081871,,,, "Direzione Trattamento Giuridico, Economico e Previdenziale",76.6666666667,23.3333333333,80.6666666667,19.3333333333,88.3522727273,11.6477272727,85.5263157895,14.4736842105,,,, Direzione Sistema Informativo Integrativo,85.3305785124,14.6694214876,83.1818181818,16.8181818182,89.0495867769,10.9504132231,89.4736842105,10.5263157895,,,, "Direzione Programmazione Finanziaria e Bilancio",76.9696969697,23.0303030303,82,18,85.4545454545,14.5454545455,83.8596491228,16.1403508772,,,, "Direzione Contabilità, Economato, Tributi",76.3257575758,23.6742424242,77.7083333333,22.2916666667,86.9565217391,13.0434782609,83.9816933638,16.0183066362,,,, Direzione Partecipazioni e Controllo Analogo,73.4848484848,26.5151515152,67.5,32.5,65.9090909091,34.0909090909,79.8245614035,20.1754385965,,,, Direzione Legale,73.3766233766,26.6233766234,78.2142857143,21.7857142857,82.4675324675,17.5324675325,81.954887218,18.045112782,,,, Direzione Pianificazione dei Servizi e delle Reti di Trasporto,84.4473007712,15.5526992288,85.754583921,14.245416079,86.1477572559,13.8522427441,83.7920489297,16.2079510703,,,, "Direzione Amministrativa Patrimonio - Provveditorato",86.1849096706,13.8150903294,84.6889952153,15.3110047847,88.7921653972,11.2078346028,85.7682619647,14.2317380353,,,, "Direzione Amministrativa Scuole e Programmazione Scolastica",86.7105263158,13.2894736842,88.244047619,11.755952381,87.5164257556,12.4835742444,86.8338557994,13.1661442006,,,, Direzione Amministrativa Strade e Viabilità,81.5789473684,18.4210526316,81.8181818182,18.1818181818,85.4922279793,14.5077720207,82.6347305389,17.3652694611,,,, "Direzione Progettazione - Gestione Progetti Speciali",78,22,76.25,23.75,86.9565217391,13.0434782609,86.0411899314,13.9588100686,,,, Direzione Gestione Tecnica del Patrimonio,81.5151515152,18.4848484848,84.3333333333,15.6666666667,84.5454545455,15.4545454545,81.0526315789,18.9473684211,,,, Direzione Gestione Tecnica Edilizia Scolastica,82.3176823177,17.6823176823,83.3333333333,16.6666666667,87.6767676768,12.3232323232,86.5497076023,13.4502923977,,,, Direzione Gestione Tecnica Strade e Viabilità,75.4799780581,24.5200219419,75.4221388368,24.5778611632,73.4090909091,26.5909090909,69.748427673,30.251572327,,,, Direzione Pianificazione Territoriale Urbanistica,84.2857142857,15.7142857143,85.6643356643,14.3356643357,89.0127388535,10.9872611465,84.3462246777,15.6537753223,,,, "Direzione Ambiente, Sviluppo del Territorio, Sanzioni",80.8859721083,19.1140278917,78.0685920578,21.9314079422,86.8637110016,13.1362889984,82.2243346008,17.7756653992,,,, Direzione Funzioni Statali e Regionali - Servizi per l\'impiego e Politiche Attive del Lavoro,82.0257826888,17.9742173112,79.5605724652,20.4394275348,79.8743300684,20.1256699316,77.4179712631,22.5820287369,,,, Totale,80.6727886949,19.3272113051,80.8539655896,19.1460344104,83.2361376673,16.7638623327,80.5904384226,19.4095615774,,,, '; 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