Regular Expressions 101

Save & Share

  • Regex Version: ver. 6
  • 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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
No Match

"
"
gm

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"([\u0009-\u000A]|\u000D|[\u0020-\u007E]|[\u00A0-\u00AC]|[\u00AE-\u017E]|[\u0187-\u0188]|\u018F|\u0197|[\u01A0-\u01A1]|[\u01AF-\u01B0]|\u01B7|[\u01CD-\u01DC]|[\u01DE-\u01DF]|[\u01E2-\u01F0]|[\u01F4-\u01F5]|[\u01F8-\u01FF]|[\u0212-\u0213]|[\u0218-\u021B]|[\u021E-\u021F]|[\u0227-\u0233]|\u0259|\u0268|\u0292|[\u02B9-\u02BA]|[\u02BE-\u02BF]|\u02C8|\u02CC|[\u1E02-\u1E03]|[\u1E06-\u1E07]|[\u1E0A-\u1E11]|[\u1E1C-\u1E2B]|[\u1E2F-\u1E37]|[\u1E3A-\u1E3B]|[\u1E40-\u1E49]|[\u1E52-\u1E5B]|[\u1E5E-\u1E63]|[\u1E6A-\u1E6F]|[\u1E80-\u1E87]|[\u1E8C-\u1E97]|\u1E9E|[\u1EA0-\u1EF9]|\u2019|\u2021|\u20AC|\u0041\u030B|\u0043(\u0300|\u0304|\u0306|\u0308|\u0315|\u0323|\u0326|\u0328\u0306)|\u0044\u0302|\u0046(\u0300|\u0304)|\u0047\u0300|\u0048(\u0304|\u0326|\u0331)|\u004A(\u0301|\u030C)|\u004B(\u0300|\u0302|\u0304|\u0307|\u0315|\u031B|\u0326|\u035F\u0048|\u035F\u0068)|\u004C(\u0302|\u0325|\u0325\u0304|\u0326)|\u004D(\u0300|\u0302|\u0306|\u0310)|\u004E(\u0302|\u0304|\u0306|\u0326)|\u0050(\u0300|\u0304|\u0315|\u0323)|\u0052(\u0306|\u0325|\u0325\u0304)|\u0053(\u0300|\u0304|\u031B\u0304|\u0331)|\u0054(\u0300|\u0304|\u0308|\u0315|\u031B)|\u0055\u0307|\u005A(\u0300|\u0304|\u0306|\u0308|\u0327)|\u0061\u030B|\u0063(\u0300|\u0304|\u0306|\u0308|\u0315|\u0323|\u0326|\u0328\u0306)|\u0064\u0302|\u0066(\u0300|\u0304)|\u0067\u0300|\u0068(\u0304|\u0326)|\u006A\u0301|\u006B(\u0300|\u0302|\u0304|\u0307|\u0315|\u031B|\u0326|\u035F\u0068)|\u006C(\u0302|\u0325|\u0325\u0304|\u0326)|\u006D(\u0300|\u0302|\u0306|\u0310)|\u006E(\u0302|\u0304|\u0306|\u0326)|\u0070(\u0300|\u0304|\u0315|\u0323)|\u0072(\u0306|\u0325|\u0325\u0304)|\u0073(\u0300|\u0304|\u031B\u0304|\u0331)|\u0074(\u0300|\u0304|\u0315|\u031B)|\u0075\u0307|\u007A(\u0300|\u0304|\u0306|\u0308|\u0327)|\u00C7\u0306|\u00DB\u0304|\u00E7\u0306|\u00FB\u0304|\u00FF\u0301|\u010C(\u0315|\u0323)|\u010D(\u0315|\u0323)|\u012A\u0301|\u012B\u0301|\u017D(\u0326|\u0327)|\u017E(\u0326|\u0327)|\u1E32\u0304|\u1E33\u0304|\u1E62\u0304|\u1E63\u0304|\u1E6C\u0304|\u1E6D\u0304|\u1EA0\u0308|\u1EA1\u0308|\u1ECC\u0308|\u1ECD\u0308|\u1EE4(\u0304|\u0308)|\u1EE5(\u0304|\u0308))"; string input = @""; 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