Regular Expressions 101

Save & Share

  • Current Version: 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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]
  • 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
Processing...

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"var datas ?= ?\{ ?(?: ?""[^""]+"" ?: ?\{ ?""titre"" ?: ?(?:(?:""(?:[^""]|\\"")*[^\\]"")|(?:'(?:[^']|\\')*[^\\]')) ?, ?(?:""\d+"" ?: ?\d+ ?(?:(?:, ?(?=(?:""\d)|\}))|(?=\}))){1,} ?\} ?(?:(?:, ?(?=[""}]))|(?=\}))){2,7}\}"; string input = @"var datas = { ""XiaoMei"": { ""titre"" : ""Xiao-Mei"", ""0"" : 113, ""1"" : 39, ""2"" : 128, ""3"" : 386, ""4"" : 481, ""5"" : 69, ""6"" : 25, ""7"" : 142, ""8"" : 141, ""9"" : 32, ""10"" : 533, ""11"" : 27, ""12"" : 87, ""13"" : 125, ""14"" : 124, ""15"" : 98, ""16"" : 531 }, ""RossBelles"": { ""titre"" : ""Scott Ross, les + belles"", ""0"" : 1, ""1"" : 9, ""2"" : 14, ""3"" : 27, ""4"" : 38, ""5"" : 103, ""6"" : 114, ""7"" : 141, ""8"" : 208, ""9"" : 213, ""10"" : 296, ""11"" : 297, ""12"" : 298, ""13"" : 299, ""14"" : 380, ""15"" : 490, ""16"" : 491, ""17"" : 492, ""18"" : 555 }, ""Ross561"": { ""titre"" : ""Scott Ross, antho. 1"", ""0"" : 33, ""1"" : 34, ""2"" : 60, ""3"" : 67, ""4"" : 69, ""5"" : 87, ""6"" : 94, ""7"" : 95, ""8"" : 96, ""9"" : 97, ""10"" : 104, ""11"" : 107, ""12"" : 113, ""13"" : 114, ""14"" : 132, ""15"" : 133, ""16"" : 140, ""17"" : 141, ""18"" : 144, ""19"" : 145 }, ""Ross562"": { ""titre"" : ""Scott Ross, antho. 2"", ""0"" : 146, ""1"" : 178, ""2"" : 187, ""3"" : 201, ""4"" : 203, ""5"" : 204, ""6"" : 205, ""7"" : 208, ""8"" : 209, ""9"" : 211, ""10"" : 212, ""11"" : 213, ""12"" : 214, ""13"" : 238, ""14"" : 239, ""15"" : 259, ""16"" : 260 }, ""Ross563"": { ""titre"" : ""Scott Ross, antho. 3"", ""0"" : 241, ""1"" : 261, ""2"" : 262, ""3"" : 298, ""4"" : 318, ""5"" : 319, ""6"" : 364, ""7"" : 365, ""8"" : 366, ""9"" : 381, ""10"" : 402, ""11"" : 403, ""12"" : 426, ""13"" : 427, ""14"" : 429, ""15"" : 455, ""16"" : 513, ""17"" : 544, ""18"" : 545 }, ""Staier"": { ""titre"" : ""Staier"", ""0"" : 427, ""1"" : 426, ""2"" : 415, ""3"" : 414, ""4"" : 209, ""5"" : 208, ""6"" : 247, ""7"" : 246, ""8"" : 513, ""9"" : 216, ""10"" : 215, ""11"" : 114, ""12"" : 113, ""13"" : 69, ""14"" : 116, ""15"" : 115, ""16"" : 395, ""17"" : 394} } "; foreach (Match m in Regex.Matches(input, pattern)) { 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