Regular Expressions 101

Save & Share

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

/
/
si

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/<div class=\"((?:[^>]*?))\">(.*?)<div class=\"((?:[^>]*?))\">((?:(?!<div ).)*?)<\/div><div class=\"((?:[^>]*?))\" title=\"((?:[^>]*?))\" style=\"((?:[^>]*?))\"><div class=\"clear\"><\/div>((?:(?!<div ).)*?)<div class=\"clear\"><\/div><div class=\"(?:(?:[^>]*?))\">((?:(?!<div ).)*?)<\/div><\/div><\/div>/si'; $str = '<div class="hide spoiler-wrap"> <div class="hide spoiler-body" title="MediaInfo&#58;">Общее<br />Полное имя : Svalka.2014.D.HDRip.1400MB.nnm-club.avi<br />Формат : AVI<br />Формат/Информация : Audio Video Interleave<br />Размер файла : 1,37 Гбайт<br />Продолжительность : 1 ч. 53 м.<br />Общий поток : 1722 Кбит/сек<br />Программа кодирования : VirtualDubMod 1.5.10.2 (build 2540/release)<br />Библиотека кодирования : VirtualDubMod build 2540/release<br /><br />Видео<br />Идентификатор : 0<br />Формат : MPEG-4 Visual<br />Профиль формата : Advanced Simple@L5<br />Параметр BVOP формата : 2<br />Параметр QPel формата : Нет<br />Параметр GMC формата : Без точки перехода<br />Параметр матрицы формата : Default (MPEG)<br />Идентификатор кодека : XVID<br />Идентификатор кодека/Подсказка : XviD<br />Продолжительность : 1 ч. 53 м.<br />Битрейт : 1265 Кбит/сек<br />Ширина : 720 пикселей<br />Высота : 304 пикселя<br />Соотношение сторон : 2,35:1<br />Частота кадров : 23,976 кадра/сек<br />Цветовое пространство : YUV<br />Субдискретизация насыщенности : 4:2:0<br />Битовая глубина : 8 бит<br />Тип развёртки : Прогрессивная<br />Метод сжатия : С потерями<br />Бит/(Пиксели*Кадры) : 0.241<br />Размер потока : 1,00 Гбайт (73%)<br />Библиотека кодирования : XviD 1.2.1 (UTC 2008-12-04)<br /><br />Аудио<br />Идентификатор : 1<br />Формат : AC-3<br />Формат/Информация : Audio Coding 3<br />Расширение режима : CM (complete main)<br />Параметр Endianness формата : Big<br />Идентификатор кодека : 2000<br />Продолжительность : 1 ч. 53 м.<br />Вид битрейта : Постоянный<br />Битрейт : 448 Кбит/сек<br />Каналы : 6 каналов<br />Расположение каналов : Front: L C R, Side: L R, LFE<br />Частота : 48,0 КГц<br />Битовая глубина : 16 бит<br />Метод сжатия : С потерями<br />Размер потока : 364 Мбайт (26%)<br />Выравнивание : Разделение по промежуткам<br />Продолжительность промежутка : 42 мс. (1,00 видеокадр)<br />Время предзагрузки промежутка : 500 мс. </div></div> <span style="text-align: center; display: block;"><span style="font-family: Georgia"><span style="font-style: italic"><span style="font-weight: bold">Скриншоты:</span></span></span><br /><a href="http://i.imgur.com/QWBp1XX.jpg" class="highslide" onclick="return hs.expand(this,{slideshowGroup: \'true\'})" rel="nofollow"><var class="postImg" title="http://i.imgur.com/x5fwIsl.jpg">&#10;</var></a> <a href="http://i.imgur.com/epCr2vm.jpg" class="highslide" onclick="return hs.expand(this,{slideshowGroup: \'true\'})" rel="nofollow"><var class="postImg" title="http://i.imgur.com/PxuhNxw.jpg">&#10;</var></a> <a href="http://i.imgur.com/m1CVJDO.jpg" class="highslide" onclick="return hs.expand(this,{slideshowGroup: \'true\'})" rel="nofollow"><var class="postImg" title="http://i.imgur.com/yq1rw0d.jpg">&#10;</var></a> <a href="http://i.imgur.com/1bnvM2E.jpg" class="highslide" onclick="return hs.expand(this,{slideshowGroup: \'true\'})" rel="nofollow"><var class="postImg" title="http://i.imgur.com/CtETZAv.jpg">&#10;</var></a> </span><br /><br /><span style="font-weight: bold">Время раздачи:</span> 24/7 (до 10 скачавших)</span></td> </tr> <tr><td colspan="2">'; $subst = ""; $result = preg_replace($re, $subst, $str, 1); echo "The result of the substitution is ".$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 PHP, please visit: http://php.net/manual/en/ref.pcre.php