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

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

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx