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

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

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html