Regular Expressions 101

Save & Share

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

/
/
g

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"\@?T\(.*?\)"; string input = @"@{ Layout = ""~/Views/Shared/_Layout.cshtml""; ViewBag.SeoTitle = T(""PVC Kapı ve Pencere Sistemleri | Gedizpen"").ToString(); ViewBag.MetaDescription = T(""Dünyada PVC Kapı ve Pencere sistemlerini oluşturan parçaların tamamını üreten tek firma olan Winhouse'un pencere ve kapı ürünleri detayları için tıklayın!"").ToString(); } <!-- =HomeSlider --> <section class=""home-slider-section""> <div class=""container""> <div class=""home-slider-wrapper""> <div class=""home-slider flexslider""> <ul class=""slides""> @foreach (var slider in ContentManager.LoadByType(""Slider"", CurrentCulture).Where(x => x.Status)) { <li> @if (!string.IsNullOrEmpty(slider.Link)) { <a href=""@slider.Link"" target=""@slider.LinkTarget""> <img src=""@MediaService.GetContentRoute((int)slider.Id, ""SliderImage"").IfNotNull(x => StaticContent(x.Url))"" alt=""@slider.Title"" data-desc=""@slider.Description""> </a> } else { <img src=""@MediaService.GetContentRoute((int)slider.Id, ""SliderImage"").IfNotNull(x => StaticContent(x.Url))"" alt=""@slider.Title"" data-desc=""@slider.Description""> } </li> } </ul> </div> </div> </div> </section> <!-- =HomeSlider --> <!-- =HomeWidgets --> <section class=""home-widgets-section""> <div class=""container""> <div class=""inner clearfix""> <div class=""home-widget home-widget-1""> <h2 class=""heading"">@T(""Haberler &amp; Duyurular"")</h2> <div class=""widget-content""> <div class=""news-slider-wrapper""> <div class=""news-slider flexslider"" data-prev="".news-slider-wrapper .prev"" data-next="".news-slider-wrapper .next""> <ul class=""slides""> @foreach (var announcement in ContentManager.LoadByType(""Announcement"", CurrentCulture).Where(x => x.Status && x.ContentCategory.GroupKey == Guid.Parse(""430D75FE-BAB8-4566-AE56-A06C515CE6D6"")).OrderByDescending(x => x.CreatedDate).Take(3)) { <li><a href=""@ContentRouteManager.GetContentRouteUrl(announcement.Id)"">@(((string)announcement.SpotText).TruncateAtWord(110))<img class=""figure"" src=""@MediaService.GetContentRoute((int)announcement.Id, ""AnnouncementImage"").IfNotNull(x => StaticContent(x.Url))"" alt=""@announcement.Title""></a></li> } </ul> </div> <a class=""prev arrow ir"" href=""javascript:;""><span>&laquo;</span></a> <a class=""next arrow ir"" href=""javascript:;""><span>&raquo;</span></a> </div> <a class=""read-more"" href=""@GetPreDefinedPageUrl(""Index"", ""Announcement"")"">@T(""Tüm Haberler"")</a> </div> </div> <div class=""home-widget home-widget-2""> <h2 class=""heading"">@T(""Size En Yakın Bayi Nerede ?"")</h2> <div class=""widget-content""> <form class=""nearest-dealer-search-form""> <div class=""input-wrapper js-select-wrapper""> @*@Html.DropDownListFor(x => x.City, Model.Cities, ""Lütfen il seçiniz..."", new { @class = ""style"" })*@ @Html.DropDownList(""City"", T(""Lütfen il seçiniz..."").ToString()) </div> <div class=""input-wrapper js-select-wrapper""> @*@Html.DropDownListFor(x => x.County, Model.Counties, ""Önce il seçiniz..."", new { @class = ""style"" })*@ @Html.DropDownList(""County"", T(""Önce il seçiniz..."").ToString()) </div> <div class=""submit-wrapper""> <a href=""javascript:;"" class=""theme-button""> <span>@T(""ARA"")</span> </a> </div> </form> </div> </div> <div class=""home-widget home-widget-3""> <h2 class=""heading"">@T(""Pencere Mühendislik Hesaplamaları"")</h2> <div class=""widget-content""> <p>@T(""Pencere uygulamasında ihtiyaç duyduğunuz pencere mühendislik hesaplamalarını yapabilirsiniz."")</p> <a class=""read-more"" href=""@GetPreDefinedPageUrl(""WindowCalculations"", ""Calculations"")"">@T(""Detaylı Bilgi"")</a> </div> </div> </div> </div> </section> <!-- =HomeWidgets --> <!-- =FeaturedLinks --> <div class=""featured-links-section""> <div class=""container""> <div class=""inner clearfix""> <div class=""featured-links""> <a href=""@ContentRouteManager.GetContentRouteUrl(""9ce86817-8a24-44b9-a32a-4dff918ada50"")"" class=""featured-link featured-link-1""> <span class=""icon""> <i class=""theme-icon-drill""></i> <span></span> </span> <strong class=""title""> @T(""<span>Pencere</span> <span>Montaj Uygulaması</span>"") </strong> </a> <a href=""@ContentRouteManager.GetContentRouteUrl(""95bd8a0d-d53b-42cb-9372-411c28d2b378"")"" class=""featured-link featured-link-2""> <span class=""icon""> <i class=""theme-icon-home""></i> <span></span> </span> <strong class=""title""> @T(""<span>Size Özel</span> <span>Pencereler</span>"") </strong> </a> <a href=""@ContentRouteManager.GetContentRouteUrl(""d0a6cecf-82c6-4705-91b4-8902073ab627"")"" class=""featured-link featured-link-3""> <span class=""icon""> <i class=""theme-icon-window""></i> <span></span> </span> <strong class=""title""> @T(""<span>Pencere</span> <span>Animasyonları</span>"") </strong> </a> <a href=""@ContentRouteManager.GetContentRouteUrl(""da4e73a9-d845-433e-bc04-8844557cdbb9"")"" class=""featured-link featured-link-4""> <span class=""icon""> <i class=""theme-icon-check""></i> <span></span> </span> <strong class=""title""> @T(""<span>FUDEL Akredite</span> <span>Pencere Laboratuarı</span>"") </strong> </a> </div> </div> </div> </div> <!-- =FeaturedLinks --> @section Head{ @Styles.Render(""~/assets/css/plugins/jquery.flexslider.min.css"") @Styles.Render(""~/assets/css/plugins/jquery.mcustomscrollbar.css"") } @section Plugins{ @Scripts.Render(""~/assets/js/plugins/jquery.flexslider.min.js"") @Scripts.Render(""~/assets/js/plugins/jquery.mcustomscrollbar.js"") }"; 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