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

/
/
msg

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?:Характеристики""\]\n*)(?<description>[^\[]*)\n"; string input = @"[et_pb_section admin_label=""section"" fullwidth=""off"" specialty=""on"" background_color=""#ffffff"" inner_shadow=""off"" parallax=""off"" parallax_method=""css"" module_class=""project-page""][et_pb_column type=""3_4"" specialty_columns=""3""][et_pb_row_inner admin_label=""row_inner""][et_pb_column_inner type=""4_4"" saved_specialty_column_type=""3_4""][et_pb_text admin_label=""Text"" background_layout=""light"" text_orientation=""left"" module_class=""project-page1""] <span style=""font-size: 1.7em; font-weight: bold;"">Проект ""Галыч"" 128,28 м.кв.</span> [/et_pb_text][/et_pb_column_inner][/et_pb_row_inner][et_pb_row_inner admin_label=""row_inner""][et_pb_column_inner type=""1_2"" saved_specialty_column_type=""3_4""][et_pb_image admin_label=""Image"" src=""http://servus.km.ua/wp-content/gallery/galych/galych.jpg?i=1297278904"" show_in_lightbox=""off"" url_new_window=""off"" animation=""off"" module_class=""project-page""] [/et_pb_image][/et_pb_column_inner][et_pb_column_inner type=""1_2"" saved_specialty_column_type=""3_4""][et_pb_text admin_label=""Project CTA"" background_layout=""dark"" text_orientation=""left"" module_class=""project-page""] <div class=""project-cta""> <div class=""project-cta-title1"">Узнайте стоимость строительства!</div> <div class=""project-cta-text""><center>[contact-form-7 id=""6802"" title=""Просчет проекта""]</center></div> </div> [/et_pb_text][/et_pb_column_inner][/et_pb_row_inner][et_pb_row_inner admin_label=""row_inner""][et_pb_column_inner type=""4_4"" saved_specialty_column_type=""3_4""][et_pb_accordion admin_label=""Accordion"" module_class=""ac-top""] [et_pb_accordion_item title=""Характеристики""] Двухэтажный дом с просторной террасой. Просторные комнаты, несмотря на малую площадь дома. Прекрасно подойдет для небольшой семьи или дачного дома. [/et_pb_accordion_item][et_pb_accordion_item title=""Технология""] <span style=""color: #666666;""><strong>Фундамент</strong> — монолитный ж/б</span><br style=""color: #666666;"" /><span style=""color: #666666;""><strong>Несущие стены</strong> — SIP панель (164мм)</span><br style=""color: #666666;"" /><span style=""color: #666666;""><strong>Перекрытия</strong> — деревянные двутавровые балки</span><br style=""color: #666666;"" /><span style=""color: #666666;""><strong>Покрытие</strong> — битумная или металлочерепица</span><br style=""color: #666666;"" /><span style=""color: #666666;""><strong>Наружная отделка</strong> — штукатурка, облицовочная плитка, природный камень</span> [/et_pb_accordion_item] [/et_pb_accordion][et_pb_tabs admin_label=""Tabs"" tab_font_size=""14"" body_font_size=""14"" use_border_color=""off"" border_color=""#ffffff"" border_style=""solid""] [et_pb_tab title=""Этажные планы"" tab_font_select=""default"" body_font_select=""default""] <img src=""http://servus.km.ua/wp-content/gallery/galych/1store.jpg?i=1483016512"" alt="" /> <b>Габариты дома:</b> 7.48м х 10.69м ПЛАН ПЕРВОГО ЭТАЖА* 1. Терраса 12.99м2 2. Гостиная 24.71м2 3. Кухня 6,88м2 4. Хол 4,62м2 5. Коридор 4,20м2 6. Прихожая 1,55м2 7. Кабинет 9,05м2 7. Терраса 11,22м2 *наши архитекторы могут изменить планировку по Вашему желанию <span style=""color: #ff0000; font-size: 1.1em; text-decoration: underline; font-weight: bold;"">БЕСПЛАТНО</span> <img src=""http://servus.km.ua/wp-content/gallery/galych/2store.jpg?i=1855892229"" alt="" /> ПЛАН ВТОРОГО ЭТАЖА* 1. Балкон 12.99м2 2. Спальня 11.86м2 3. Коридор 1,31м2 4. Спальня 15,68м2 5. Балкон 11,22м2 *наши архитекторы могут изменить планировку по Вашему желанию <span style=""color: #ff0000; font-size: 1.1em; text-decoration: underline; font-weight: bold;"">БЕСПЛАТНО</span> [/et_pb_tab][et_pb_tab title=""Фасады"" tab_font_select=""default"" body_font_select=""default""] <img src=""http://servus.km.ua/wp-content/gallery/galych/fasad1.jpg?i=1221828987"" alt="" />  <img src=""http://servus.km.ua/wp-content/gallery/galych/fasad2.jpg?i=648025905"" alt="" /> <img src=""http://servus.km.ua/wp-content/gallery/galych/fasad3.jpg?i=1573804814"" alt="" />  <img src=""http://servus.km.ua/wp-content/gallery/galych/fasad4.jpg?i=1604215263"" alt="" /> &nbsp; &nbsp; [/et_pb_tab][et_pb_tab title=""Фото готового дома""] Проект еще не построен, или находится на стадии строительства [/et_pb_tab] [/et_pb_tabs][/et_pb_column_inner][/et_pb_row_inner][/et_pb_column][et_pb_column type=""1_4""][et_pb_text admin_label=""Европейский сертификат"" background_layout=""light"" text_orientation=""left"" module_class=""project-page1""] <p style=""text-align: center;""><img class=""wp-image-3276 size-full"" style=""margin-left: 3px; margin-right: 3px; float: left;"" src=""http://servus.km.ua/wp-content/uploads/eu_logo.jpg"" alt=""eu_logo"" width=""100"" height=""64"" /><span style=""font-size: 1.2em; font-weight: bold; line-height: 1.3em;"">Европейский сертификат</span> <a title=""Посмотреть сертификат"" href=""http://servus.km.ua/o-kompanii/sertifikatyi"">Посмотреть</a> <span style=""font-size: 1.1em;"">Строим в Украине и Европе по европейским стандартам</span></p> [/et_pb_text][et_pb_text admin_label=""Text"" background_layout=""light"" text_orientation=""left""] <a class=""button-help"" style=""color: #ffffff; font-weight: bold;"" href=""http://servus.km.ua/project/podbor-proekta-po-parametram""><span style=""margin: 0 auto;"">Помочь с выбором проекта?</span></a> [/et_pb_text][et_pb_text admin_label=""Реализованные проекты"" background_layout=""light"" text_orientation=""left"" module_class=""project-page-top project-page-bottom""] <p style=""text-align: center; font-size: 1.2em;""><strong>Реализованные проекты</strong></p> [/et_pb_text][et_pb_slider admin_label=""Slider"" show_arrows=""on"" show_pagination=""off"" auto=""on"" "; RegexOptions options = RegexOptions.Multiline | RegexOptions.Singleline; foreach (Match m in Regex.Matches(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