Regular Expressions 101

Save & Share

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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)>[\r\n\s]*\b([0-9a-zA-Zàè ,\s\r\n]+)\b[\s\r\n]*<" Local $sString = "@extends('frontend.layout')" & @CRLF & _ "" & @CRLF & _ "@section('mainsection')" & @CRLF & _ " <section class="mainsection">" & @CRLF & _ " <div class="row d-none d-lg-flex fe_row_breadcrumbs mx-0">" & @CRLF & _ " <div class="col-10 py-4 px-0 d-flex justify-content-between">" & @CRLF & _ " <div class="d-flex align-items-center justify-content-start"><a href="/"" & @CRLF & _ " class="breadcrumbs_parent">" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "Home" & @CRLF & _ "</a><span class="breadcrumbs_slash"> / </span><a href="/chi-siamo/"" & @CRLF & _ " class="breadcrumbs_cur">Storia</a></div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="row d-flex justify-content-center row_storia my-4">" & @CRLF & _ " <div class="col-10 mb-3 d-none d-lg-flex">" & @CRLF & _ " <h1 class="fe_title1">" & @CRLF & _ " Chi siamo" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " </h1>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-12 col-lg-10">" & @CRLF & _ " <div class="row">" & @CRLF & _ " <div class="col-12 col-lg-6 mt-3 order-2 order-lg-1">" & @CRLF & _ " <p class="fe_text4 interlinea1 pr-0 pr-lg-5">" & @CRLF & _ " <strong>Fabbricatorino</strong> è una azienda storica che nasce negli anni ’20 come “Società" & @CRLF & _ " Anonima Fabbrica Torino” specializzata nella produzione di oggetti e componenti in" & @CRLF & _ " <strong>bachelite</strong>. Il suo avvicinamento al mondo degli occhiali fu del tutto casuale," & @CRLF & _ " si narra infatti che fu all’<strong>Autodromo di Monza</strong> in occasione del “Gran Premio" & @CRLF & _ " Automobilistico d’Autunno” durante i festeggiamenti per la vittoria di <strong>Maserati" & @CRLF & _ " Alfieri</strong> su <strong>Auto " & @CRLF & _ "" & @CRLF & _ "Diatto 3 Litri</strong>, che i fondatori di Fabbricatorino" & @CRLF & _ " si proposero per fornire al gruppo gli “<strong>occhiali da gara</strong>” per i loro piloti." & @CRLF & _ " </p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-12 col-lg-6 mt-3 d-flex justify-content-center align-items-center order-1 order-lg-2">" & @CRLF & _ " <img src="https://www.occhialifabbricatorino.it/images/banner/it/aboutus/bg-chisiamo.jpg"" & @CRLF & _ " class="img-fluid">" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-12 col-lg-6 mt-3 order-4 order-lg-3">" & @CRLF & _ " <p class="fe_text4 interlinea1">" & @CRLF & _ " Il <strong>DNA innovativo</strong> dell’azienda portò verso la fine degli anni ‘30 alla" & @CRLF & _ " sperimentazione di <strong>nuovi materiali</strong> primo fra tutti l’<strong>acetato</strong>," & @CRLF & _ " recente scoperta di un chimico belga, destinato negli anni a venire a diventare il materiale per" & @CRLF & _ " eccellenza per l’occhialeria artigianale di alta qualità." & @CRLF & _ " </p>" & @CRLF & _ " <p class="fe_text4 interlinea1">" & @CRLF & _ " In seguito, sulla scia dei primi successi di “<strong>PERSOL</strong>”, nuova linea di occhiali" & @CRLF & _ " destinata nel futuro ad impreziosire la fama dell’industria cittadina, Fabbricatorino iniziò lo" & @CRLF & _ " studio e la produzione di <strong>occhiali da sole e da vista</strong> non solo per uso" & @CRLF & _ " industriale e sportivo ma anche per la <strong>vita di tutti i giorni</strong>." & @CRLF & _ " </p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-12 col-lg-6 mt-3 d-flex justify-content-center align-items-center order-3 order-lg-4">" & @CRLF & _ " <img src="/images/storia2.png" class="img-fluid mr-2 maxWidth">" & @CRLF & _ " <img src="/images/storia3.png" class="img-fluid ml-2 maxWidth">" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-12 col-lg-6 mt-3 d-flex justify-content-center align-items-center order-5 order-lg-5">" & @CRLF & _ " <img src="/images/storia4.png" class="img-fluid mr-2 maxWidth">" & @CRLF & _ " <img src="/images/storia5.png" class="img-fluid ml-2 maxWidth">" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-12 col-lg-6 mt-3 order-6 order-lg-6">" & @CRLF & _ " <p class="fe_text4 interlinea1">" & @CRLF & _ " Da sempre sinonimo di <strong>alta qualità italiana</strong> i nostri occhiali sono fresati dal" & @CRLF & _ " pieno da lastre di acetato, <strong>lavorate a mano dai nostri artigiani</strong> e tutti i" & @CRLF & _ " passaggi che portano alla nascita del prodotto sono curati con una <strong>attenzione" & @CRLF & _ " maniacale</strong>. Fabbricatorino realizza i propri prodotti per tutti coloro che non hanno" & @CRLF & _ " bisogno di seguire le mode ma vogliono imporre il proprio <strong>unico modo di essere</strong>." & @CRLF & _ " </p>" & @CRLF & _ " <p class="fe_text4 interlinea1">" & @CRLF & _ " Le nostre linee seducono una nicchia di consumatori curiosi e attenti, che cercano in un" & @CRLF & _ " prodotto la <strong>bellezza</strong> e l’<strong>esclusività</strong> uniti ai valori di" & @CRLF & _ " <strong>innovazione, tradizione e sostenibilità</strong>." & @CRLF & _ " </p>" & @CRLF & _ " </div>" & @CRLF & _ " <div" & @CRLF & _ " class="col-12 fe_storia_contact justify-content-center align-items-center mt-4 d-none d-lg-flex order-7 order-lg-7">" & @CRLF & _ " <span>Vuoi parlare con noi</span>" & @CRLF & _ " <a href="mailto:info@fabbricatorino.it"><i class="material-icons">markunread</i></a>" & @CRLF & _ " <a href="tel:0110712545"><i class="material-icons">call</i></a>" & @CRLF & _ " </div> " & @CRLF & _ " </div>" & @CRLF & _ " <div class="row d-flex justify-content-center d-lg-none">" & @CRLF & _ " <div class="col-8 d-flex justify-content-center">" & @CRLF & _ " <div class="fe_storia_category"" & @CRLF & _ " onclick="this.style.display=&quot;none&quot;;this.nextElementSibling.classList.remove(&quot;d-none&quot;);this.nextElementSibling.nextElementSibling.classList.remove(&quot;d-none&quot;);">" & @CRLF & _ " <a>" & @CRLF & _ " Scopri la collezione <strong style="text-transform:uppercase">VISTA</strong> </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="d-none fe_storia_genderW">" & @CRLF & _ " <a href="/vista/?gender=F">" & @CRLF & _ " Donna </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="d-none fe_storia_genderU">" & @CRLF & _ " <a href="/vista/?gender=U">" & @CRLF & _ " Uomo </a>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="row d-flex justify-content-center d-lg-none mt-3">" & @CRLF & _ " <div class="col-8 d-flex justify-content-center">" & @CRLF & _ " <div class="fe_storia_category"" & @CRLF & _ " onclick="this.style.display=&quot;none&quot;;this.nextElementSibling.classList.remove(&quot;d-none&quot;);this.nextElementSibling.nextElementSibling.classList.remove(&quot;d-none&quot;);">" & @CRLF & _ " <a>" & @CRLF & _ " Scopri la collezione <strong style="text-transform:uppercase">SOLE</strong> </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="d-none fe_storia_genderW">" & @CRLF & _ " <a href="/sole/?gender=F">" & @CRLF & _ " Donna </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="d-none fe_storia_genderU">" & @CRLF & _ " <a href="/sole/?gender=U">" & @CRLF & _ " Uomo </a>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " </section>" & @CRLF & _ "@endsection" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm