Regular Expressions 101

Save & Share

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

/
/
g

Test String

Code Generator

Generated Code

$re = '/(.+)(?:[Ss _\.](\d{2,})[Ee _\.](\d{2,}))[\. _](\d{3,4}p)?(.+)?.*?\-(.+?)(?:\[(.+)\])?\.(\w+)/'; $str = 'Ridiculousness.S07E15.HDTV.x264-TASTETV[eztv].mp4 Portlandia.S06E03.HDTV.x264-KILLERS[eztv].mp4 Life.in.Pieces.S01E15.HDTV.x264-KILLERS[eztv].mp4 Portlandia.S06E03.720p.HDTV.x264-KILLERS[eztv].mkv Idiotsitter.S01E04.HDTV.x264-KILLERS[eztv].mp4 Lip.Sync.Battle.S02E05.720p.HDTV.x264-ALTEREGO[eztv].mkv Lip.Sync.Battle.S02E05.HDTV.x264-ALTEREGO[eztv].mp4 Shades.of.Blue.S01E05.720p.HDTV.x264-AVS[eztv].mkv Shades.of.Blue.S01E05.720p.HDTV.x264-FLEET[eztv].mkv Colony.S01E04.720p.HDTV.x264-KILLERS[eztv].mkv Shades.of.Blue.S01E05.HDTV.x264-FLEET[eztv].mp4 Baskets.S01E03.INTERNAL.720p.HDTV.x264-KILLERS[eztv].mkv Baskets.S01E03.INTERNAL.HDTV.x264-KILLERS[eztv].mp4 Workaholics.S06E04.720p.HDTV.x264-KILLERS[eztv].mkv Baskets.S01E03.HDTV.x264-FLEET[eztv].mp4 Baskets.S01E03.720p.HDTV.x264-FLEET[eztv].mkv The.Blacklist.S03E13.720p.HDTV.x264-AVS[eztv].mkv The.100.S03E03.720p.HDTV.x264-AVS[eztv].mkv Angel.From.Hell.S01E05.HDTV.x264-LOL[eztv].mp4 Angel.From.Hell.S01E05.720p.HDTV.X264-DIMENSION[eztv].mkv The.100.S03E03.HDTV.x264-FLEET[eztv].mp4 Mom.S03E10.HDTV.x264-LOL[eztv].mp4 Mom.S03E10.720p.HDTV.X264-DIMENSION[eztv].mkv Life.in.Pieces.S01E15.720p.HDTV.x264-AVS[eztv].mkv Elementary.S04E11.HDTV.x264-LOL[eztv].mp4 Elementary.S04E11.720p.HDTV.X264-DIMENSION[eztv].mkv DCs.Legends.of.Tomorrow.S01E03.HDTV.x264-LOL[eztv].mp4 The.Vampire.Diaries.S07E11.HDTV.x264-LOL[eztv].mp4 DCs.Legends.of.Tomorrow.S01E03.720p.HDTV.X264-DIMENSION[eztv].mkv The.Vampire.Diaries.S07E11.720p.HDTV.X264-DIMENSION[eztv].mkv Saving.Hope.S04E16.HDTV.x264-BAJSKORV[eztv].mp4 Saving.Hope.S04E16.720p.HDTV.x264-BAJSKORV[eztv].mkv The.Big.Bang.Theory.S09E14.HDTV.x264-LOL[eztv].mp4 The.Ellen.DeGeneres.Show.2016.02.04.HDTV.x264-ALTEREGO[eztv].mp4 The.Ellen.DeGeneres.Show.2016.02.04.720p.HDTV.x264-ALTEREGO[eztv].mkv Teachers.2016.S01E04.REPACK.720p.HDTV.x264-ALTEREGO[eztv].mkv Celebrity.Big.Brothers.Bit.On.The.Side.S10E24.720p.HDTV.x264-C4TV[eztv].mkv Long.Island.Medium.S07E03.HDTV.x264-CRiMSON[eztv].mp4 Celebrity.Big.Brothers.Bit.On.The.Side.S10E24.HDTV.x264-C4TV[eztv].mp4 Clarence.US.S02E06.Time.Crimes.720p.HDTV.x264-W4F[eztv].mkv Clarence.US.S02E06.Time.Crimes.HDTV.x264-W4F[eztv].mp4 Clarence.US.S02E05.Ren.Faire.720p.HDTV.x264-W4F[eztv].mkv Clarence.US.S02E05.Ren.Faire.HDTV.x264-W4F[eztv].mp4 Great.British.Railway.Journeys.Series.7.05of20.Ashley.to.Alton.720p.x264.HDTV[eztv].mp4 Celebrity.Big.Brother.S17E35.HDTV.x264-C4TV[eztv].mp4 James.Corden.2016.02.03.Rosie.ODonnell.HDTV.x264-TASTETV[eztv].mp4 James.Corden.2016.02.03.Rosie.ODonnell.720p.HDTV.x264-TASTETV[eztv].mkv Mr Robot S01E10 2015 HDTV x264 - SPARKS.wmv'; 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