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

/
/
si

Test String

Code Generator

Generated Code

re = /<div class="(.*?) video-item">(.*?)href="([^"]*)"(.*?)data-get-thumbs-url="([^"]*)"(.*?)alt="([^"]*)"(.*?)src='([^']*)'(.*?)<div class="timer hidden-xs">(\s*)<p>([0-9]*)(.*?)<\/p><\/div>(.*?)<div class="description">(\s*)<p>(.*?)<\/p>(.*?)<p class="title-video">(.*?)<\/p>(.*?)<div class="infos-video">(.*?)<p>Le ([0-9][0-9])\/([0-9][0-9])\/([0-9][0-9][0-9][0-9])<\/p>(\s*)<p>([0-9 ]*?)vues<\/p>(.*?)<\/div>(.*?)<div class="cat-video">(\s*)(.*?)(\s*)<\/div>(\s*?)<\/div>/i str = ' <div class="col-md-3 col-sm-4 col-xs-6 video-item"> <a target="_blank" data-popunder-enabled href="/videos/show/1983/sandrine-teste-la-double.html"> <div class="thumb-video"> <img class="videoThumb" data-get-thumbs-url="/video/1983/thumbnails_262x196.json" alt="Double pénétration, Double vaginale, Sodomie" src=\'http://m.tv2.cdn.jetm-tech.net/cache/4a/c5/4ac5ff7ae42612bfc68139740700ea0c.jpg\' /> <div class="timer hidden-xs"> <p>47 min</p></div> <div class="description"> <p>Notre équipe retrouve Sandrine devant le château de Blois pour constater, une fois de plus, que cette timide historienne de 31ans est une sacrée chaudasse ! …</p> </div> </div> <p class="title-video"> Sandrine teste la double&nbsp;!</p> <div class="infos-video"> <p>Le 12/10/2015</p> <p>1 876 156 vues</p> </div> </a> <div class="cat-video"> <p>Catégories : <a href="/tag/1/double-penetration.html">Double pénétration</a>, <a href="/tag/2/double-vaginale.html">Double vaginale</a>, <a href="/tag/8/sodomie.html">Sodomie</a></p> </div> </div> <div class="col-md-3 col-sm-4 col-xs-6 video-item"> <a target="_blank" data-popunder-enabled href="/videos/show/1982/soizic-passe-un-entretien-dembauche.html"> <div class="thumb-video"> <img class="videoThumb" data-get-thumbs-url="/video/1982/thumbnails_262x196.json" alt="Cougar, Scénario, Sodomie" src=\'http://m.tv2.cdn.jetm-tech.net/cache/cc/e5/cce55a7502d51aaefc049ee83334653c.jpg\' /> <div class="timer hidden-xs"> <p>30 min</p></div> <div class="description"> <p>Quand Soizic, 40ans, de Saint-Malo, et l&#39;ami Rick se font un petit plan un brin pervers... Pour voir ses vidéos, mettez Soizic dans la recherche. Parlez en …</p> </div> </div> <p class="title-video"> Soizic passe un entretien d\'embauche&nbsp;!</p> <div class="infos-video"> <p>Le 11/10/2015</p> <p>1 882 538 vues</p> </div> </a> <div class="cat-video"> <p>Catégories : <a href="/tag/23/cougar.html">Cougar</a>, <a href="/tag/56/scenario.html">Scénario</a>, <a href="/tag/8/sodomie.html">Sodomie</a></p> </div> </div> <div class="col-md-3 col-sm-4 col-xs-6 video-item"> <a target="_blank" data-popunder-enabled href="/videos/show/1981/lola-se-libere.html"> <div class="thumb-video"> <img class="videoThumb" data-get-thumbs-url="/video/1981/thumbnails_262x196.json" alt="Double pénétration, Sodomie, Trio HHF" src=\'http://m.tv2.cdn.jetm-tech.net/cache/f3/5b/f35b23b16f81588dda16702cec5ef284.jpg\' /> <div class="timer hidden-xs"> <p>42 min</p></div> <div class="description"> <p>Sa première vidéo a eu de telles vertus thérapeutiques que Lola surmonte désormais tous ses complexes et va même jusqu&#39;à nous entraîner chez un de ses nouveaux…</p> </div> </div> <p class="title-video"> Lola se libère&nbsp;!</p> <div class="infos-video"> <p>Le 10/10/2015</p> <p>1 717 096 vues</p> </div> </a> <div class="cat-video"> <p>Catégories : <a href="/tag/1/double-penetration.html">Double pénétration</a>, <a href="/tag/8/sodomie.html">Sodomie</a>, <a href="/tag/21/trio-hhf.html">Trio HHF</a></p> </div> </div> ' # Print the match result str.match(re) do |match| puts match.to_s end

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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html