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

/
/
gsiU

Test String

Substitution

Processing...

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r#"(?siU)http:\/\/link\.2gis\.ru\/\d\.\d.*(https?.*")"#).unwrap(); let string = "{\"meta\":{\"code\":200,\"api_version\":\"2.0.1.6.401\",\"issue_date\":\"20171227\"},\"result\":{\"total\":1,\"items\":[{\"reg_bc_url\":\"https://stat.api.2gis.ru/?hash=zflyh9p8p7023113012GGG2c9j4x5x26G6G42466G57123H7rgewB419175IG1I1GAG5I4GJcz99uvG45446203472H1H4B2&v=2.0\",\"name\":\"TechnoPoint, дисконт-центр\",\"point\":{\"lat\":55.754353,\"lon\":52.410458},\"contact_groups\":[{\"contacts\":[{\"type\":\"phone\",\"text\":\"8‒800‒700‒46‒66\",\"value\":\"88007004666\",\"comment\":\"круглосуточная единая справочная - пн-вс\"},{\"type\":\"website\",\"text\":\"www.technopoint.ru\",\"value\":\"http://link.2gis.ru/1.2/DEC186FE/online/20171201/project29/70000001022405020/2gis.ru/zflyh9p8p7023113016GGGba9j4x5x26G6G42466G57123H7rgewB419175IG1I1GAG5I4GJcz99uvG45446203472H1H4B2?http://www.technopoint.ru\"},{\"type\":\"vkontakte\",\"text\":\"https://vk.com/technopoint_club\",\"value\":\"https://vk.com/technopoint_club\"},{\"type\":\"odnoklassniki\",\"text\":\"https://ok.ru/technopoint\",\"value\":\"https://ok.ru/technopoint\"}]}],\"flags\":{\"photos\":false},\"name_ex\":{\"primary\":\"TechnoPoint\",\"extension\":\"дисконт-центр\"},\"external_content\":[{\"type\":\"photo_album\",\"count\":3,\"subtype\":\"view\",\"main_photo_url\":\"https://i3.photo.2gis.com/main/geo/29/4082022817479773/view\"}],\"attribute_groups\":[{\"name\":\"Способы оплаты\",\"attributes\":[{\"tag\":\"general_payment_type_cash\",\"name\":\"Наличный расчет\"},{\"tag\":\"general_payment_type_bank\",\"name\":\"Оплата через банк\"},{\"tag\":\"general_payment_type_internet\",\"name\":\"Оплата через Интернет\"}],\"rubric_ids\":[]}],\"rubrics\":[{\"name\":\"Аудиотехника / Видеотехника\",\"parent_id\":\"3\",\"short_id\":511,\"alias\":\"audiotekhnika_videotekhnika\",\"id\":\"511\",\"kind\":\"primary\"},{\"name\":\"Бытовая техника\",\"parent_id\":\"3\",\"short_id\":379,\"alias\":\"bytovaya_tekhnika\",\"id\":\"379\",\"kind\":\"primary\"},{\"name\":\"Компьютеры / Комплектующие\",\"parent_id\":\"3\",\"short_id\":181,\"alias\":\"kompyutery_komplektuyushhie\",\"id\":\"181\",\"kind\":\"primary\"},{\"name\":\"Мобильные телефоны\",\"parent_id\":\"19532\",\"short_id\":643,\"alias\":\"mobilnye_telefony\",\"id\":\"643\",\"kind\":\"primary\"}],\"region_id\":\"29\",\"adm_div\":[{\"id\":\"4082048587268177\",\"name\":\"Новый Город\",\"type\":\"living_area\"}],\"see_also\":[{\"name\":\"Matrix, торгово-сервисная фирма\",\"main_photo_url\":\"https://i2.photo.2gis.com/main/branch/29/4081915443287042/common\",\"point\":{\"lat\":55.74556,\"lon\":52.436246},\"name_ex\":{\"primary\":\"Matrix\",\"extension\":\"торгово-сервисная фирма\"},\"stat\":{\"rubr\":\"181\",\"adsalg\":4,\"adst\":1514304900},\"id\":\"4081915443287042_flyh9cz2G45446A263G3H1JJ7H889j4x5xzG4p8p702G43B2A0323033wB426G63A3G5GG455533A23H1I6H99uvrge19AB2I32H294J80224061\",\"ads\":{\"text\":\"Гарантия качества, индивидуальный подход, постгарантийное обслуживание\"},\"address_comment\":\"2 этаж\",\"address\":{\"postcode\":\"423815\",\"components\":[{\"type\":\"street_number\",\"number\":\"26\",\"street\":\"53-й комплекс\",\"street_id\":\"4082125896681047\"}],\"building_id\":\"4082022817470932\"},\"address_name\":\"53-й комплекс, 26\",\"type\":\"branch\",\"org\":{\"id\":\"4081924033221092\",\"name\":\"Matrix, торгово-сервисная фирма\",\"branch_count\":1}},{\"name\":\"Мобильный Рай, салон\",\"point\":{\"lat\":55.705664,\"lon\":52.346043},\"name_ex\":{\"primary\":\"Мобильный Рай\",\"extension\":\"салон\"},\"stat\":{\"rubr\":\"181\",\"adsalg\":4,\"adst\":1514304900},\"id\":\"70000001028678031_flyh9cz2G45446AA241J25J3IH7H9j4x5xzG4p8p702G733117323032wB426G63A3G5GG3021298051G37H99uvrge19AB2I3H2H2B4H10224169f\",\"ads\":{\"text\":\"Запчасти для вашего компьютера по низким ценам!\",\"text_warning\":\"ИП Фащук Инга Робертовна, ОГРН 315165000018409\",\"options\":{\"logo\":{\"img_url\":\"https://cdn.ams.2gis.com/a866c0ed-1c6c-4ff0-9e4b-91bb7a5177bf/8941283a0d615a4ce782501c23ebe61c7664e1aa/image.png\",\"bg_color\":\"#2a85a5\",\"text_color\":\"#FFFFFF\"},\"actions\":[{\"value\":\"http://link.2gis.ru/1.2/A2AACB71/online/20171201/project29/70000001028678031/2gis.ru/flyh9cz2G45446AA241J25J57HI69j4x5xzG4p8p703G733117323032wB426G63A3G5GG3021298051G37H99uvrge19AB2I3H2H2B4H1022416H87?https://www.mob-rai.ru/index.php?option=com_jshopping&controller=category&task=view&category_id=1&Itemid=117\",\"name\":\"Посмотреть каталог\",\"type\":\"link\"}],\"discount\":true},\"warning\":\"ИП Фащук Инга Робертовна, ОГРН 315165000018409\"},\"address_comment\":\"49 павильон; 1 этаж\",\"address\":{\"postcode\":\"423803\",\"components\":[{\"type\":\"street_number\",\"number\":\"36\",\"street\":\"Сергея Титова\",\"street_id\":\"4082125896680005\"}],\"building_id\":\"4082022817472178\",\"building_name\":\"Арзан\"},\"address_name\":\"Сергея Титова, 36\",\"type\":\"branch\",\"org\":{\"id\":\"70000001026553747\",\"name\":\"Мобильный Рай, салон\",\"branch_count\":2}},{\"name\":\"Radeon, выездной сервисный центр по ремонту и настройке компьютерной техники и мобильных устройств\",\"point\":{\"lat\":55.746473,\"lon\":52.416012},\"name_ex\":{\"primary\":\"Radeon\",\"extension\":\"выездной сервисный центр по ремонту и настройке компьютерной техники и мобильных устройств\"},\"stat\":{\"rubr\":\"181\",\"adsalg\":4,\"adst\":1514304900},\"id\":\"4081915443292453_flyh9cz2G454465674G5HH3JI6I99j4x5xzG4p8p702G43B2A0323033wB426G63A3G5GG455533B23H17I599uvrge19AB2I32H294J802240616\",\"ads\":{\"text\":\"Покупаем продаем ноутбуки, компьютеры и комплектующие.\",\"options\":{\"logo\":{\"img_url\":\"https://cdn.ams.2gis.com/4bff868a-02e3-4d17-a588-ed72ffba65aa/3578d1b1f73e3354735e58920340afc6537d0c37/image.png\",\"bg_color\":\"#228484\",\"text_color\":\"#FFFFFF\"},\"discount\":true}},\"address_comment\":\"1 этаж; 4 подъезд\",\"address\":{\"postcode\":\"423810\",\"components\":[{\"type\":\"street_number\",\"number\":\"16\",\"street\":\"1-й комплекс\",\"street_id\":\"4082125896679736\"}],\"building_id\":\"4082022817464710\"},\"address_name\":\"1-й комплекс, 16\",\"type\":\"branch\",\"org\":{\"id\":\"4081924033225363\",\"name\":\"Radeon, выездной сервисный центр по ремонту и настройке компьютерной техники и мобильных устройств\",\"branch_count\":3}},{\"name\":\"БелФорт, ООО, компания\",\"point\":{\"lat\":55.755859,\"lon\":52.407623},\"name_ex\":{\"primary\":\"БелФорт, ООО\",\"extension\":\"компания\"},\"stat\":{\"rubr\":\"181\",\"adsalg\":4,\"adst\":1514304900},\"id\":\"4081915443407206_flyh9cz2G45446A427G6HH3JI6Ig9j4x5xzG4p8p702G43B2A0323033wB426G63A3G5GG455535223H17I599uvrge19AB2I32H294J80224061g\",\"ads\":{\"text\":\"МФУ, копиры, принтеры. Продажа, обслуживание, ремонт\",\"options\":{\"logo\":{\"img_url\":\"https://cdn.ams.2gis.com/61bfbe1d-f411-48f0-92b8-5678f4e34d7c/be49b7203a4a9e3d643bffbe4078d451ee6e77a3/image.png\",\"bg_color\":\"#dc231c\",\"text_color\":\"#FFFFFF\"},\"actions\":[{\"value\":\"http://link.2gis.ru/1.2/788B0BDE/online/20171201/project29/4081915443407206/2gis.ru/flyh9cz2G45446A427G6HH58IH7H9j4x5xzG4p8p703G43B2A0323033wB426G63A3G5GG455535223H17I599uvrge19AB2I32H294J80224061db?http://belfort.ru/Netshop/\",\"name\":\"Выбрать по каталогу\",\"type\":\"link\"}],\"discount\":true}},\"address_comment\":\"1 этаж\",\"address\":{\"postcode\":\"423816\",\"components\":[{\"type\":\"street_number\",\"number\":\"35\",\"street\":\"47-й комплекс\",\"street_id\":\"4082125896680562\"}],\"building_id\":\"4082022817467768\"},\"address_name\":\"47-й комплекс, 35\",\"type\":\"branch\",\"org\":{\"id\":\"4081924033220711\",\"name\":\"БелФорт, ООО, компания\",\"branch_count\":1}},{\"name\":\"Гелиос, компания\",\"point\":{\"lat\":55.731386,\"lon\":52.395147},\"name_ex\":{\"primary\":\"Гелиос\",\"extension\":\"компания\"},\"stat\":{\"rubr\":\"181\",\"adsalg\":4,\"adst\":1514304900},\"id\":\"4081915443307891_flyh9cz2G45446AAB2G7H1JJ7HBg9j4x5xzG4p8p702G43B2A0323033wB426G63A3G5GG455534223H1I6H99uvrge19AB2I32H294J80224061\",\"ads\":{\"text\":\"Компьютеры, ноутбуки. Купите у нас – настроим, доставим бесплатно.\",\"text_warning\":\"Подробности по тел. +7 (8552) 31–15–55.\",\"warning\":\"Подробности по тел. +7 (8552) 31–15–55.\"},\"address_comment\":\"2 этаж; 2 подъезд\",\"address\":{\"postcode\":\"423812\",\"components\":[{\"type\":\"street_number\",\"number\":\"14а\",\"street\":\"11-й комплекс\",\"street_id\":\"4082125896679797\"}],\"building_id\":\"4082022817472116\"},\"address_name\":\"11-й комплекс, 14а\",\"type\":\"branch\",\"org\":{\"id\":\"4081924033217430\",\"name\":\"Гелиос, компания\",\"branch_count\":1}}],\"links\":{\"entrances\":[{\"id\":\"4082430871656427\",\"geometry\":{\"points\":[\"POINT(52.410294 55.754137)\"],\"normals\":[\"LINESTRING(53.271311 55.245561,52.410294 55.754137)\"],\"vectors\":[\"LINESTRING(52.410404 55.754072,52.410294 55.754137)\"]},\"is_primary\":true}],\"nearest_stations\":[{\"id\":\"4082173141319817\",\"name\":\"45-й комплекс\",\"distance\":170,\"route_types\":[\"bus\",\"shuttle_bus\"]}]},\"id\":\"70000001022405020\",\"dates\":{\"created_at\":\"2016-04-04T06:00:00+03:00\",\"updated_at\":\"2017-12-20T21:33:07+03:00\"},\"address_comment\":\"цокольный этаж\",\"reviews\":{\"is_reviewable_on_flamp\":true,\"general_rating\":2.5,\"items\":[{\"tag\":\"flamp\",\"rating\":2.6,\"review_count\":5,\"is_reviewable\":true},{\"tag\":\"foursquare\",\"is_reviewable\":true}],\"org_review_count\":5,\"review_count\":5,\"rating\":2.6,\"org_rating\":2.5,\"general_review_count\":5,\"is_reviewable\":true},\"schedule\":{\"Thu\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]},\"Sat\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]},\"Tue\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]},\"Sun\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]},\"Mon\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]},\"Wed\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]},\"Fri\":{\"working_hours\":[{\"to\":\"21:00\",\"from\":\"10:00\"}]}},\"address\":{\"postcode\":\"423816\",\"components\":[{\"type\":\"street_number\",\"number\":\"67в\",\"street\":\"Сююмбике проспект\",\"street_id\":\"4082125896679528\"}],\"building_id\":\"4082022817479773\",\"building_name\":\"на Сююмбике\"},\"address_name\":\"Сююмбике проспект, 67в\",\"type\":\"branch\",\"org\":{\"id\":\"70000001022405019\",\"name\":\"TechnoPoint, дисконт-центр\",\"branch_count\":1},\"group\":null}]}}"; let substitution = "$1"; // result will be a String with the substituted value let result = regex.replace_all(string, substitution); println!("{}", result); }

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 Rust, please visit: https://docs.rs/regex/latest/regex/