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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/\-\s([a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]*)|([a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z.]{3,})\//m'; $str = '24.06.2022 - Статьи на внешку - 6 - Челомова - vitok.ua.docx - Google Docs https://real-vin.com/ispravlenie-prikusa-u-detej-plastinami-osobennosti https://md-eksperiment.org/ru/post/20181030-protezirovanie-zubov-estetika-vidy-harakteristiki https://md-eksperiment.org/ru/post/20181030-protezirovanie-zubov-estetika-vidy-harakteristiki http://strichka.com/article/121746444 https://video.news.rin.ru/news_text/201741/ https://video.news.rin.ru/news/201741/ https://chdtu.edu.ua/ndi-chdtu/conferences-chdtu https://strichka.com/article/121458075 https://obcity.gov.ua/2022/06/01/vseukrainska-stipendialna-programa-skyclinic-scholarship/ https://cikavosti.com/vazhn-e-prychyn-ne-terpet-bol-a-posetyt-stomatoloha-v-kyeve/ https://www.zaholovok.com.ua/u-chomu-plyusi-ta-osoblivosti-implantativ-straumann https://zaholovok.com.ua/u-chomu-plyusi-ta-osoblivosti-implantativ-straumann https://svaliava.rayon.in.ua/news/513952-tri-osnovni-sposobi-vipravlennya-prikusu-u-ditey https://uzhgorod.net.ua/news/167547 https://www.uzhgorod.net.ua/news/167547 https://www.healthinfo.ua/articles/zdorovaia_gigiena/57875 https://kriptohit.ru/articles/chto-delat-esli-proglotil-breket.html https://protocol.ua/ua/pochemu-otbelivanie-zubov-nado-provodit-u-stomatologa-kieve/ https://nuft.edu.ua/studentu/vazhliva-nformaczya/konkurs-za-inicziativi-naczionalnogo-memorialnogo-kompleksu https://nuft.edu.ua/studentu/vazhliva-nformaczya/konkurs-za-inicziativi-naczionalnogo-memorialnogo-kompleksu https://zhzh.info/news/2014-09-19-20583 https://www.poznavayka.org/anatomiya-i-meditsina/plyusy-i-minusy-ligaturnyh-breketov-stoit-li-ustanavlivat/ https://protocol.ua/ru/pochemu-otbelivanie-zubov-nado-provodit-u-stomatologa-kieve/ https://vz.ua/news/76398-bezopasna-li-odnomomentnaya-implantaciya-zubov https://rusjev.net/2022/04/19/chto-takoe-otbelivanie-beyond/ https://shipovnik.ua/novosti/89279 https://eukraina.com/news/osobennosti_nesemnykh_zubnykh_protezov_kak_vybrat_podkhodjashhie/2022-02-19-26517 http://rusjev.net/2022/04/19/chto-takoe-otbelivanie-beyond/ https://healthinfo.ua/articles/zdorovaia_gigiena/57875 https://kharkovblog.info/pnews/implantaty-megagen-v-chem-osobennosti-i-preimushestva/ https://glavnoe.ua/news/n357084592-skolko-dlitsya-odnomomentnaya-implantaciya-zuba https://onmedu.edu.ua/zaproshuiemo-prijnjati-uchast-u-scholarship-socialnij-programi-dlja-studentiv-ta-abituriientiv/ https://gorod.dp.ua/news/158085'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php