Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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

/
/
giu

Test String

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"(?iu)(?:Расположение|\G(?!\A)).*?([а-яё][\s\.\,\-а-яё]*[а-яё])").unwrap(); let string = "<div class=\"line-tit\">Цена</div><div class=\"line-val\"><span class=\"price-more\"><span class=\"price-more-list\"><i>5 950 000 ₽</i><i>80 297 $</i><i>67 818 €</i></span><b class=\"price-value\">5 950 000 ₽</b></span></div><div class=\"line-tit\">Год выпуска</div><div class=\"line-val\">2020</div><div class=\"line-tit\">Расположение</div><div class=\"line-val line-val-bubble\"><span>ёМосква и еще <span class=\"ext-city-list\" data-cf-modified-876940278ac4b007a0e51228-=\"\" onclick=\"if (!window.__cfRLUnblockHandlers) return false; openTBC()\">31 город</span></span><div class=\"trade__bubble-cities\"><div class=\"closeBtn\" data-cf-modified-876940278ac4b007a0e51228-=\"\" onclick=\"if (!window.__cfRLUnblockHandlers) return false; closeTBC()\">+</div><div class=\"trade__bubble-cities-sign\"></div><p>Предложение актуально для следующих городов:</p><div class=\"trade__bubble-cities__list\"><ul><li>Белгород</li><li>Владивосток</li><li>Волгоград</li><li>Вологда</li><li>Воронеж</li><li>Екатеринбург</li><li>Иркутск</li><li>Казань</li><li>Киров</li> <li>Краснодар</li><li>Красноярск</li><li>Липецк</li><li>Москва</li><li>Набережные Челны</li><li>Нижний Новгород</li><li>Новокузнецк</li><li>Новосибирск</li><li>Пенза</li><li>Пермь</li><li>Пятигорск</li><li>Ростов-на-Дону</li><li>Самара</li><li>Санкт-Петербург</li><li>Саратов</li><li>Симферополь</li><li>Ставрополь</li><li>Сургут</li><li>Томск</li><li>Тюмень</li><li>Уфа</li><li>Чебоксары</li><li>Челябинск</li></ul></div></div></div> "; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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/