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
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 = '/(?<=\<h3\>).+(?=\<\/h3\>)/m'; $str = '<h3>COVEMA</h3> <h3>PALMERO</h3> <h3>PLASTIFERRO</h3> <h3>UOCRA</h3> <h3>REPAS</h3> <h3>BTU</h3> <h3>PANEDILE</h3> <h3>ELEPRINT</h3> <h3>JOSÉ J. CHEDIACK</h3> <h3>NIRO CONSTRUCCIONES</h3> <h3>HELPORT</h3> <h3>BISCAYNE</h3> <h3>COARCO</h3> <h3>ESUCO</h3> <h3>CPC</h3> <h3>TEL 3</h3> <h3>CARTELLONE</h3> <h3>MACRO</h3> <h3>VIAL AGRO</h3> <h3>ISOLUX CORSÁN</h3> <h3>AFCP</h3> <h3>FINNING</h3> <h3>ROGGIO</h3> <h3>ROVELLA CARRANZA</h3> <h3>ACINDAR</h3> <h3>IERIC</h3> <h3>IGARRETA MÁQUINAS</h3> <h3>RIVA</h3> <h3>GRUPO ESTISOL</h3> <h3>IECSA</h3> <h3>ARMAFERRO</h3> <h3>BRICONS</h3> <h3>CNH INDUSTRIAL</h3> <h3>PAOLINI</h3> <h3>SERVIUR</h3> <h3>SANDVIK</h3> <h3>DECAVIAL</h3> <h3>ODEBRECHT</h3> <h3>ENAS</h3> <h3>SITRA</h3> <h3>SUPERCEMENTO</h3> <h3>JCR</h3> <h3>CONSTRUMEX</h3> <h3>BRIALES</h3> <h3>CAPUTO</h3> <h3>LUCIANO</h3> <h3>GALICIA</h3> <h3>VICTOR CONTRERAS</h3> <h3>SIKA ARGENTINA</h3> <h3>CRIBA</h3> <h3>BOETTO Y BUTTIGLIENGO</h3> <h3>MILICIC</h3> <h3>PERIODICO EL CONSTRUCTOR</h3> <h3>PHONERENTAL</h3> <h3>DOS ARROYOS</h3> <h3>MARTINEZ Y DE LA FUENTE</h3> <h3>AUSA</h3> <h3>LUIS LOSI</h3> <h3>AESA</h3> <h3>CONSTRUCTORA SUDAMERICANA</h3> <h3>PLANTEL</h3> <h3>PCR</h3> <h3>BANCO DE LA NACIÓN ARGENTINA</h3> <h3>SUBTERRÁNEOS DE BUENOS AIRES</h3> <h3>HOLA SIM</h3> <h3>JOSÉ LUIS TRIVIÑO</h3> <h3>TECHINT</h3> <h3>EDUARDO COLOMBI</h3> <h3>ALEMARSA</h3> <h3>CENTRO CONSTRUCCIONES</h3> <h3>TECNIPISOS</h3> <h3>XAPOR</h3> <h3>FONTANA NICASTRO</h3> <h3>CONCRET-NOR</h3> <h3>DYCASA</h3> <h3>BURGWARDT</h3> <h3>SULLAIR</h3> <h3>FONDO FIDUCIARIO FEDERAL DE INFRAESTRUCTURA REGIONAL</h3> <h3>FLOWTEX</h3> <h3>PETERSEN THIELE Y CRUZ</h3> <h3>LIHUÉ</h3> <h3>IRAM</h3> <h3>ESTUDIO YMAZ</h3> <h3>VIDOGAR</h3> <h3>BICE</h3> <h3>ROMERO CAMMISA</h3> <h3>BATIMAT</h3> <h3>ALBA CAUCIÓN</h3> <h3>PROBA</h3> <h3>ICF</h3> <h3>TECMA</h3> <h3>ALESTE</h3> <h3>DELEGACIÓN PROVINCIA DE BUENOS AIRES</h3> <h3>HIDRAVIAL</h3> <h3>BANCO CIUDAD</h3> <h3>LAMANNA</h3>'; 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