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 = '/^(?:[a-z\d][a-z\d_-]*[a-z\d])(?:\.(?:[a-z\d][a-z\d_-]*[a-z\d]))*@(?:\d*[a-z]{2,}\d*)+\.(?:\d*[a-z]{2,}\d*)+(?:.(?:\d*[a-z]{2,}\d*)+)*$/m'; $str = 'Datos de prueba en el regex101 jessy2995@hotmail.com jessica.altamirano@epn.edu.ec carlosfandradev7b@hotmail.com carlos.andrade03@epn.edu.ec gracegbm@hotmail.es grace.borja@epn.edu.ec jose-andes15@hotmail.com jose.canar@epn.edu.ec fabrizzio40@hotmail.com fabrizzio.capito@epn.edu.ec alexstv001@gmail.com alex.carrillo@epn.edu.ec caro.cerezor@gmail.com johanna.cerezo@epn.edu.ec franco_chopan@live.com francisco.cevallos01@epn.edu.ec steandres_94@yahoo.com estefan.cevallos@epn.edu.ec jairocka00@hotmail.com jairo.chancusig@epn.edu.ec alexcuentasnna@gmail.com freddy.coronel@epn.edu.ec david3505@hotmail.com david.cruz@epn.edu.ec fabio-a1514@hotmail.com fabio.enriquez@epn.edu.ec jordy.lig@gmail.com jordy.flor@epn.edu.ec burmamachoy@hotmail.com jose.garcia01@epn.edu.ec bryangavilema@gmail.com bryan.gavilema@epn.edu.ec edwin.paul.73@gmail.com edwin.guamushig@epn.edu.ec dannylexuz@gmail.com danny.herrera@epn.edu.ec aaron_hidalgo23@hotmail.com aaron.hidalgo@epn.edu.ec xavi18rod@gmail.com rodman.iniguez@epn.edu.ec jairomanzaba@hotmail.com jhon.manzaba@epn.edu.ec andhy_mosquera@hotmail.com andy.mosquera@epn.edu.ec jose719810@hotmail.com jose.murillo01@epn.edu.ec veronica_198825@hotmail.com veronica.olmedo@epn.edu.ec pato18djul@gmail.com marco.parco@epn.edu.ec loplaand@hotmail.com pablo.pillajo@epn.edu.ec diegoaporterol@hotmail.com diego.portero@epn.edu.ec jl_quilumba@hotmail.com jorge.quilumba@epn.edu.ec mishellcrm@hotmail.com mishell.real@epn.edu.ec hpaulsalazar96@hotmail.com henry.salazar01@epn.edu.ec santiagosarmiento1996@hotmail.com santiago.sarmiento@epn.edu.ec stalindario96@hotmail.com stalin.toaquiza@epn.edu.ec andres.liguista@hotmail.com bryan.torres01@epn.edu.ec alexiscdmovil@live.com jonathan.vilatuna@epn.edu.ec cristhian.zapata@epn.edu.ec jordansalazar17@hotmail.co11.ec cris_777_666@yahoo.com 777_666@ya8ho8ou.com Correo electrónico inválido cristh_slbf_@hotmail.com 777_666@y6ahoo.com alphanumerico alphanum.@alphanumo@gmail.com alphanumerico@.com.my alphanum.erico@c.om.my alphanumerico123@gmail.a alphanumerico@gmail.com.c1a .alphanumerico@alphanumerico.com alphanumerico.@alphanumerico.com a~l!p<h>(a)u$n%m^e*r[i]c{o} @tj.ec alphanumerico@gm*ail.co%m alphanumerico@-gm_ail.co-m alphanumerico..2002@gmail.com alphanumerico@gmail.com. '; 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