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
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

/
/
gmi

Test String

Code Generator

Generated Code

$re = '/the.100.S01E\d{1,2}.*720p.*hun.eng.*sln|the.100.S\d{1,2}.*720p.*hun.eng.*sln/mi'; $str = 'The.100.S07.1080p.BluRay.x264-BORDURE The.100.S07.720p.BluRay.x264-BORDURE The 100 - S05 - The Complete 5th Season [ 3 BD50 ] 2018 Blu-ray AVC DTS-HD MA5.1 - d69a74 The 100 - S04 - The Complete 4th Season [ 3 BD ] 2017 Blu-ray AVC DTS-HD MA5.1 - d69a74 The 100 - S03 - The Complete 3rd Season [ 4 BD ] 2016 Blu-ray AVC DTS-HD MA5.1 - d69a74 The 100 - S02 - The Complete 2nd Season [ 4 BD ] 2014-2015 Blu-ray AVC DTS-HD MA5.1 - d69a74 The 100 - S01 -The Complete 1st Season [ 3 BD ] 2014 Blu-ray AVC DTS-HD MA5.1 - d69a74 The.100.S06.1080p.BluRay.x264-TURMOiL The.100.S06.720p.BluRay.x264-MAYHEM A visszatérők S05 1080p The.100.S05.COMPLETE.720p.BluRay.HUN.ENG.x264-SLN A visszatérők S04 1080p The.100.S04.COMPLETE.720p.BluRay.HUN.ENG.DD5.1.x264-SLN A visszatérők S03 1080p The.100.S03.COMPLETE.720p.BluRay.x264.HUN.ENG-SLN The.100.S04.1080p.BluRay.x264-SHORTBREHD A visszatérők S02 1080p The.100.S02.COMPLETE.720p.BluRay.x264.HUN.ENG-SLN The.100.S02.720p.HDTV.x264-MiXGROUP The.100.S04.720p.HDTV.x264-MiXGROUP The.100.S03.1080p.HDTV.x264-DIMENSION The.100.S01.1080p.BluRay.DTS.x264.Hun-HOONIGAN The.100.S01.COMPLETE.720p.BluRay.x264.HUN-ENG-SLN The 100 S01 1080p The.100.S02.1080p.BluRay.x264-SHORTBREHD The.100.S02.720p.BluRay.X264-REWARD Family.Guy.S19E04.HULU.WEB-DL.DDP5.1.H264.Eng.Hun-BNR.1080p Family.Guy.S19E02.1080p.HULU.WEB-DL.DDP5.1.H264.Eng.Hun-BNR Family.Guy.S19E03.WEBRip.x264.Hun-BNR Family.Guy.S19E02.720p.HULU.WEB-DL.DDP5.1.H264.Eng.Hun-BNR Family.Guy.S19E20.1080p.WEB.H264-CAKES Deluge-YaRSS2'; 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