Regular Expressions 101

Save & Share

  • Regex Version: ver. 4
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

/
/
i

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 = "(\\r\\n|\\n|\\r|\\t)"; final String string = "zweigeshoff@southwestern.com\n" + "Zwarren@tristatetruck.com\n" + "zoning@jeffersoncountytn.gov\n" + "znunley@fpcnashville.org\n" + "ZMYERS@NPMMG.COM\n" + "zmart.stations@gmail.com\n" + "ZLOVELADY@AZORINC.COM\n" + "zlinkous0904@musfiber.com\n" + "zjackson@guardianhealthcare.com\n" + "zippyrf@gmail.com\n" + "zimmermanm@wcschools.com\n" + "zhou2209@hotmail.com\n" + "zhashmi@ornlfcu.com\n" + "ZGANN@TEMPLEHILLSGOLF.COM\n" + "zfoster@spicerfirm.com\n" + "zeisloftsb@msha.com\n" + "zdut@aol.com\n" + "Zc@poncelaw.com\n" + "zazzyz@gmail.com\n" + "zahuczkyj@wcschools.com\n" + "zacharyebryant@mac.com\n" + "zachary.moore@mnps.org\n" + "zacharc@wcschools.com\n" + "zac.seiber@ttecasting.com\n" + "YVONNER@CAPITOLCASH1.COM\n" + "yvonne.rossi@starpt.COM\n" + "yvonne.leonard@cumulus.com\n" + "YVONNE.CHELTON@MNPS.ORG\n" + "Yvette.Robinson@Nashville.gov\n" + "yroebuck@pstcc.edu\n" + "YPARR@UTM.EDU\n" + "YOUNKERJ@BELLSOUTH.NET\n" + "YOUNGSHIL27@YAHOO.COM\n" + "youngs.animal.hospital@comcast.net\n" + "Youngde@rcschools.net\n" + "youngbs@msha.com\n" + "youngab@msha.com\n" + "young.vickiel@yahoo.com\n" + "younce@crossroadstn.com\n" + "yorkke@msha.com\n" + "yohel@rcschools.net\n" + "YMJ@ROWLANDANDCARTER.COM\n" + "yjoyner@ci.collierville.tn.us\n" + "yjones@tcatcovington.edu\n" + "yhanash@comcast.net\n" + "YHALL@OLDREPUBLICTITLE.COM\n" + "yfrazier@mmc.edu\n" + "yercheckta@msha.com\n" + "YEAGER.KRISTEN@COGENTHMG.COM\n" + "YDONATTO@OAKWOOD.EDU\n" + "ycutler@bellsouth.net\n" + "ycollier@aol.com\n" + "YCARPENTER@VOLUNTEEREXPRESS.COM\n" + "yateskh@msha.com\n" + "yarberbf@msha.com\n" + "yakima.wa@carehere.com\n" + "xxx\n" + "xcovington14@yahoo.com\n" + "XAVIERA.WASHINGTON@MNPS.ORG\n" + "WynneJL2@msha.com\n" + "wyelverton@madisoncountyal.gov\n" + "wyattj@rcschools.net\n" + "wyatt@suppliesnetwork.com\n" + "WWW.VERTKSOLUTIONSINC.COM\n" + "WWW.VERTEKSOLUTIONSINC.COM\n" + "WWW.TURNERCONSTRUCTION.COM\n" + "WWW.TLSINC.COM\n" + "WWW.THEHANNAHCOMPANY.COM\n" + "WWW.TEAMNOXCUSE.COM\n" + "WWW.SPICERFIRM.COM\n" + "WWW.SENTRYSTEEL.COM\n" + "www.northsidedisiples.com\n" + "WWW.MONARCHMORTGAGETN.COM\n" + "WWW.LIGHTWAVESOLARELECTRIC.COM\n" + "www.innovative-eyecare.com\n" + "www.holisticalabama.com\n" + "www.decantermachine.com\n" + "WWW.BACKFIELDINMOTION.ORG\n" + "www.athens-orthodontics.com\n" + "www.allneedzrental.com\n" + "WWW.ALLERGYASC.COM\n" + "WWTPLANT@PULASKI-TN.COM\n" + "WWHITESIDE@HARDINANDPARKES.COM\n" + "WWHITE@CBCDECATUR.ORG\n" + "wweaver@alphapetinc.com\n" + "wwatkins@rutherfordcountytn.gov\n" + "wwasserman@vofonline.org\n" + "Wwalls@Systemstechnologyco.com\n" + "WVENABLE@CITYOFSCOTTSBORO.COM\n" + "WVAUGHN@OAKWOOD.EDU\n" + "wurmserbp@msha.com\n" + "WTROPER@HSVUTIL.ORG\n" + "wths@bellsouth.net\n" + "wthayer@dyersburgtn.gov\n" + "WTERRY@DECATUR-AL.GOV\n"; final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); final Matcher matcher = pattern.matcher(string); if (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