Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • 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]
  • 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 = @"<(.)*>"; string input = @"<p><b>Vancouver</b> (<span class=""rt-commentedText nowrap""><span class=""IPA nopopups noexcerpt""><a href=""/wiki/Help:IPA/English"" title=""Help:IPA/English"">/<span style=""border-bottom:1px dotted""><span title=""'v' in 'vie'"">v</span><span title=""/æ/: 'a' in 'bad'"">æ</span><span title=""'n' in 'nigh'"">n</span><span title=""/ˈ/: primary stress follows"">ˈ</span><span title=""'k' in 'kind'"">k</span><span title=""/uː/: 'oo' in 'goose'"">uː</span><span title=""'v' in 'vie'"">v</span><span title=""/ər/: 'er' in 'letter'"">ər</span></span>/</a></span> <span class=""nowrap"" style=""font-size:85%"">(<span class=""unicode haudio""><span class=""fn""><span style=""white-space:nowrap;margin-right:.25em;""><a href=""/wiki/File:EN-Vancouver.ogg"" title=""About this sound""><img alt=""About this sound"" src=""//upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/11px-Loudspeaker.svg.png"" decoding=""async"" srcset=""//upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/17px-Loudspeaker.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/22px-Loudspeaker.svg.png 2x"" data-file-width=""20"" data-file-height=""20"" width=""11"" height=""11""></a></span><a href=""//upload.wikimedia.org/wikipedia/commons/4/44/EN-Vancouver.ogg"" class=""internal"" title=""EN-Vancouver.ogg"">listen</a></span></span>)</span></span> <a href=""/wiki/Help:Pronunciation_respelling_key"" title=""Help:Pronunciation respelling key""><i title=""English pronunciation respelling"">van-<span style=""font-size:90%"">KOO</span>-vər</i></a>) is a major city in <a href=""/wiki/Western_Canada"" title=""Western Canada"">western Canada</a>, located in the <a href=""/wiki/Lower_Mainland"" title=""2016 Canadian Census"">Lower Mainland</a> region of <a href=""/wiki/British_Columbia"" title=""British Columbia"">British Columbia</a>. As the <a href=""/wiki/List_of_cities_in_British_Columbia"" title=""List of cities in British Columbia"">most populous city</a> in the province, the <a href=""/wiki/2016_Canadian_Census"" class=""mw-redirect"" title="">2016 census</a> recorded 631,486 people in the city, up from 603,502 in 2011. The <a href=""/wiki/Greater_Vancouver"" title=""Greater Vancouver"">Greater Vancouver</a> area had a population of 2,463,431 in 2016, making it the <a href=""/wiki/List_of_census_metropolitan_areas_and_agglomerations_in_Canada#List"" title="">third-largest metropolitan area in Canada</a>. Vancouver has the highest population density in Canada, with over 5,400 people per square kilometre.<sup id=""cite_ref-5"" class=""reference""><a href=""#cite_note-5"">[5]</a></sup><sup id=""cite_ref-6"" class=""reference""><a href=""#cite_note-6"">[6]</a></sup> Vancouver is one of the most <a href=""/wiki/Ethnic_origins_of_people_in_Canada"" title=""Ethnic origins of people in Canada"">ethnically</a> and linguistically diverse cities in Canada: 52 percent of its residents are not native English speakers,<sup id=""cite_ref-pop2006-Van_7-0"" class=""reference""><a href=""#cite_note-pop2006-Van-7"">[7]</a></sup><sup id=""cite_ref-8"" class=""reference""><a href=""#cite_note-8"">[8]</a></sup> 48.9 percent are native speakers of neither English nor French, and 50.6 percent of residents belong to <a href=""/wiki/Visible_minority"" title=""Visible minority"">visible minority</a> groups.<sup id=""cite_ref-9"" class=""reference""><a href=""#cite_note-9"">[9]</a></sup> </p>"; 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