Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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

/
/
mg

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"; string input = @"{""_id"":{""$oid"":""572a5b82ae5174d3c4177d6b""},""email"":""dj292023@gmail.com"",""gender"":""F"",""zip"":""29203"",""state"":""SC"",""city"":""Columbia"",""address1"":""5137 LINDELLA ST"",""last_name"":""Jones"",""first_name"":""Debra"",""updatedAt"":{""$date"":""2016-09-28T12:17:21.610Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:37.860Z""},""job"":""Cashier""} {""_id"":{""$oid"":""572a5b82ae5174d3c4177d6c""},""email"":""killaswag2345@gmail.com"",""updatedAt"":{""$date"":""2016-05-04T20:28:38.123Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:38.123Z""}} {""_id"":{""$oid"":""572a5b83ae5174d3c4177d6d""},""email"":""crandall656@gmail.com"",""gender"":""M"",""last_name"":""Crandall"",""first_name"":""Andrew"",""updatedAt"":{""$date"":""2016-09-20T02:28:58.710Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:39.175Z""},""zip"":""37738"",""state"":""TN"",""city"":""Gatlinburg"",""address1"":""1048 LANCEWOOD DR""} {""_id"":{""$oid"":""572a5b85ae5174d3c4177d6e""},""email"":""bre7117@gmail.com"",""gender"":""F"",""zip"":""75962"",""state"":""TX"",""city"":""NACOGDOCHES"",""address1"":""19942 CRESTED HILL"",""last_name"":""HEARD"",""first_name"":""BRIANA"",""updatedAt"":{""$date"":""2016-08-30T11:02:57.810Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:40.650Z""},""job"":""membership sales associate""} {""_id"":{""$oid"":""572a5b85ae5174d3c4177d6f""},""email"":""35ellie@gmail.com"",""zip"":""83402"",""state"":""ID"",""city"":""EAGLE ROCK"",""address1"":""416N 3900E"",""last_name"":""STAUFFER"",""first_name"":""ELLIZABETH"",""updatedAt"":{""$date"":""2016-05-04T20:28:41.218Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:41.218Z""}} {""_id"":{""$oid"":""572a5b7992338558326a9355""},""updatedAt"":{""$date"":""2016-05-30T13:44:05.943Z""},""createdAt"":{""$date"":""2016-05-04T20:28:41.745Z""},""email"":""silshadow@yahoo.com"",""ip"":""76.2.67.68"",""first_name"":""Del"",""last_name"":""Soltis"",""address1"":"",""city"":"",""state"":"",""zip"":""44417"",""phone"":"",""dob"":"",""inAccountName"":""IA_EDU1"",""__v"":0} {""_id"":{""$oid"":""572a5b86ae5174d3c4177d70""},""email"":""travistalbert645@yahoo.com"",""gender"":""M"",""zip"":""20001"",""state"":""DC"",""city"":""WASHINGTON"",""address1"":""1703 2ND ST NW"",""last_name"":""TALBERT"",""first_name"":""TRAVIS"",""updatedAt"":{""$date"":""2016-09-21T14:56:31.811Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:42.103Z""},""job"":""Inventory Stocker""} {""_id"":{""$oid"":""572a5b7a92338558326a9358""},""updatedAt"":{""$date"":""2016-05-04T20:28:42.508Z""},""createdAt"":{""$date"":""2016-05-04T20:28:42.508Z""},""email"":""mark_88_11@yahoo.com"",""ip"":""174.124.192.43"",""first_name"":""Mark"",""last_name"":""Jenkins"",""address1"":"",""city"":"",""state"":"",""zip"":"",""phone"":"",""dob"":"",""inAccountName"":""IA_EDU1"",""__v"":0} {""_id"":{""$oid"":""572a5b7b741c393b3257df25""},""updatedAt"":{""$date"":""2016-05-04T20:28:43.109Z""},""createdAt"":{""$date"":""2016-05-04T20:28:43.109Z""},""first_name"":""Oliver"",""last_name"":""Dawanda"",""zip"":""28012"",""email"":""dawanda28@yahoo.com"",""ip"":""127.0.0.1"",""inAccountName"":""MPM_EDU2"",""gender"":""M"",""__v"":0} {""_id"":{""$oid"":""572a5b88ae5174d3c4177d71""},""email"":""greene015@gmail.com"",""gender"":""M"",""zip"":""33102"",""state"":""FL"",""city"":""MIAMI"",""address1"":""995 MASON TURNER RD"",""last_name"":""GREENE"",""first_name"":""JOHNATHAN"",""updatedAt"":{""$date"":""2016-05-11T08:30:22.287Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:43.620Z""},""job"":""Warehouse""} {""_id"":{""$oid"":""572a5b88ae5174d3c4177d72""},""email"":""kadance30@gmail.com"",""gender"":""M"",""zip"":""27536"",""state"":""NC"",""city"":""HENDERSON"",""address1"":""357 SOUTHALL ST"",""last_name"":""MARROW"",""first_name"":""QUENTIN"",""updatedAt"":{""$date"":""2016-05-04T20:32:29.702Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:44.404Z""}} {""_id"":{""$oid"":""572a5b89ae5174d3c4177d73""},""email"":""kanalou76@gmail.com"",""zip"":""37217"",""state"":""TN"",""city"":""Nashville-Davidson metropolitan gove"",""address1"":""491 millwood dr"",""last_name"":""kane"",""first_name"":""alassane"",""updatedAt"":{""$date"":""2016-06-18T06:47:00.719Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:44.790Z""}} {""_id"":{""$oid"":""572a5b89ae5174d3c4177d74""},""email"":""gereperez1040@gmail.com"",""zip"":""78574"",""state"":""TX"",""city"":""Mission"",""address1"":""6001 Elise Dr."",""last_name"":""Perez"",""first_name"":""Geremias"",""updatedAt"":{""$date"":""2016-08-11T20:32:52.988Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:45.033Z""},""job"":""Sales"",""dob"":""10-17-1996"",""gender"":""M"",""phone"":""9566413280""} {""_id"":{""$oid"":""572a5b89ae5174d3c4177d75""},""email"":""cayman64@hotmail.com"",""gender"":""M"",""zip"":""29323"",""state"":""SC"",""city"":""CHESNEE"",""last_name"":""ROBINSON"",""first_name"":""DEBBIE"",""updatedAt"":{""$date"":""2016-07-13T01:03:34.129Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:45.189Z""},""address1"":""1058 BUCK CREEK RD"",""job"":""Marketing"",""dob"":""5/25/1951"",""phone"":""8644617766""} {""_id"":{""$oid"":""572a5b89ae5174d3c4177d76""},""email"":""shataviasadler@gmail.com"",""zip"":""77084"",""state"":""TX"",""city"":""HOUSTON"",""address1"":""1227 HELMS RD"",""last_name"":""SADLER"",""first_name"":""SHATAVIA"",""updatedAt"":{""$date"":""2016-05-23T20:13:19.725Z""},""__v"":0,""createdAt"":{""$date"":""2016-05-04T20:28:45.227Z""}} {""_id"":{""$oid"":""572a5b7dac39fe75320e5f83""},""updatedAt"":{""$date"":""2016-06-18T18:54:49.336Z""},""createdAt"":{""$date"":""2016-05-04T20:28:45.299Z""},""email"":""hwatso@aol.com"",""ip"":""65.15.99.190"",""first_name"":""Joyce"",""last_name"":""Watson"",""city"":""TERRY"",""state"":""MS"",""zip"":""39170"",""inAccountName"":""R3I_FYDN"",""gender"":""F"",""__v"":0} {""_id"":{""$oid"":""572a5b7d741c393b3257df2c""},""updatedAt"":{""$date"":""2016-05-04T20:28:45.496Z""},""createdAt"":{""$date"":""2016-05-04T20:28:45.496Z""},""email"":""staciechess@yahoo.com"",""ip"":""107.77.106.92"",""first_name"":""Stacie"",""last_name"":""CHESS"",""city"":""Meadville"",""state"":""PA"",""zip"":""16335"",""inAccountName"":""R3I_FYDN"",""gender"":""F"",""__v"":0} {""_id"":{""$oid"":""572a5b7d92338558326a9361""},""updatedAt"":{""$date"":""2016-05-27T12:34:51.274Z""},""createdAt"":{""$date"":""2016-05-04T20:28:45.700Z""},""email"":""robert.siler@att.net"",""ip"":""108.89.195.49"",""first_name"":""Robert"",""last_name"":""Siler"",""city"":""Cypress"",""state"":""CA"",""zip"":""90630"",""inAccountName"":""R3I_FYDN"",""gender"":""M"",""__v"":0}"; 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