Regular Expressions 101

Save & Share

  • Regex Version: ver. 43
  • 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
No Match

@"
"

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?<error>.+)"; string input = @"/P <</MCID 0 >>BDC 1 g /GS0 gs 203.42 454.87 148.01 76.464 re f* EMC /Artifact BMC q 51.36 206.66 509.64 530.38 re W* n 0.749 g 50.88 375.53 509.76 10.584 re f* Q q 51.36 206.66 509.64 530.38 re W* n 0.749 g 50.88 302.45 509.76 10.56 re f* EMC Q /P <</MCID 1 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /GS1 gs /TT0 6.48 Tf 67.08 622.42 Td [(D)3.997 (ate:)6.003 ( )]TJ ET EMC Q /P <</MCID 2 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf 110.06 622.42 Td [(4)7.006 (/1)3.997 (8)6.991 (/2)4.012 (0)6.991 (2)7.006 (4)]TJ ET EMC Q /P <</MCID 3 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf 52.2 604.54 Td [(C)-2.994 (u)5.988 (st)4.012 (o)7.994 (mer Name:)6.003 ( )]TJ ET EMC Q /P <</MCID 4 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf 160.82 604.54 Td [(V)-6.003 (er)-3.997 (sal)7.006 (i)7.994 (f)8.997 (t)]TJ ET EMC Q /P <</MCID 5 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf 358.99 604.54 Td [(A)5 (d)6.003 (d)6.003 (re)-4.012 (ss)4.012 (:)]TJ ET EMC Q /P <</MCID 6 >>BDC q 388.99 593.86 59.424 25.68 re W* n BT 0 g /TT0 6.48 Tf 389.83 604.78 Td [(7)7.006 (6)6.991 (0)7.006 (1)6.991 ( )4.012 (I)-6.003 (mp)8.997 (er)-3.997 (i)7.994 (al)5 ( )3.997 (D)4.012 (ri)5 (v)7.994 (e )]TJ ET Q q 388.99 593.86 59.424 25.68 re W* n BT 0 g /TT0 6.48 Tf 389.83 596.26 Td [(Wac)-2.994 (o)7.994 (,)8.997 ( )3.997 (T)6.003 (X )3.997 (7)7.006 (6)7.006 (7)6.991 (1)7.006 (2)]TJ ET EMC Q /P <</MCID 7 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf 52.2 556.18 Td [(C)-2.994 (u)5.988 (st)4.012 (o)7.994 (mer Par)-3.997 (t )5 (Nu)3.997 (mb)8.997 (er)-3.997 (:)8.997 ( )]TJ ET EMC Q /P <</MCID 8 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf 160.94 556.18 Td [(2)7.006 (1)6.991 (6)7.006 (7)6.991 (8)7.006 (-)-7.994 (1)]TJ ET EMC Q /P <</MCID 9 >>BDC q 51.36 206.66 509.64 530.38 re W* n BT 0 g /TT0 6.48 Tf -0.0454 Tc 226.73 556.18 Td [(1007922-)-15 (1)] [(h)1.000 ]"; Match m = Regex.Match(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