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

/
/
Ui

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif))"; string input = @"<a style=""display:block;"" href=""javascript:void(0);"" onclick=""expandImageRotate ( 'xImage_56362441','http://snpi.dell.com/snp/images/products/large/en-th~370-ACMK/370-ACMK.jpg',event,this,'' );""><img id=""xImage_56362441_sm_Image"" border=""0"" alt=""Dell 8 GB Certified Replacement Memory Module for Select Dell Systems- UDIMM ECC"" title=""Dell 8 GB Certified Replacement Memory Module for Select Dell Systems- UDIMM ECC"" width=""200"" src=""http://snpi.dell.com/snp/images/products/mlrg/en-th~370-ACMK/370-ACMK.jpg"" z></a> </span></td></tr> <tr><td colspan=""2"" style=""padding: 15px 0px 5px 0px""><table cellpadding=""4"" cellspacing=""0"" align=""center"" border=""0""><tr class=""thumbnailRow""><td align=""center""><table cellpadding=""0"" cellspacing=""0"" border=""0""> <tr> <td><img src=""http://i.dell.com/images/global/brand/ui/top_left_small.gif"" width=""3"" height=""3""></td> <td width=""100%""><img src=""http://i.dell.com/images/global/brand/ui/top_horiz_small.gif"" width=""100%"" height=""3"" border=""0""></td> <td class=""rightAlign""><img src=""http://i.dell.com/images/global/brand/ui/top_right_small.gif"" width=""3"" height=""3""></td> </tr> <tr> <td class=""leftVertSmall""></td> <td><span style=""display:inline-block;width:40px;""> <script type=""text/javascript""> RegisterImage('original_image', 'http://snpi.dell.com/snp/images/products/mlrg/en-th~370-ACMK/370-ACMK.jpg', 'http://snpi.dell.com/snp/images/products/large/en-th~370-ACMK/370-ACMK.jpg', ""Dell 8 GB Certified Replacement Memory Module for Select Dell Systems- UDIMM ECC"", 'xImage_18637405', ''); </script><div style=""position: absolute; top: 0pt; left: 0pt;"" id=""xImage_18637405_container""></div>"; RegexOptions options = RegexOptions.IgnoreCase; Match m = Regex.Match(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