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

/
/
gi

Test String

Code Generator

Generated Code

re = /(.+?)[\.\s](?:(?:(\d{4})[\.\s])(S\d{1,2}(?:E\d{1,2})?)|(?:(\d{4})[\.\s])|(S\d{1,2}(?:E\d{1,2}(?:\-E?\d{1,2})?)?)|(?:720p|1080p))[\.\s]?(.*)[\.\s]/i str = 'Maze.Runner.The.Scorch.Trials.2015.NORDiC.REMUX.BluRay.1080p.AVC.DTS-HD.MA7.1-iRL Get.Santa.2014.DKsubs.1080p.BluRay.x264-GenX Two.Step.2014.Custom.DKsubs.1080p.WEB-DL.h264-SUBLiME Heroes.Reborn.S01E10.Retail.DKsubs.720p.HDTV.x264-RAPiDCOWS The.Transporter.Refueled.2015.DKSUBS.1080p.BluRay.x264-iRL Maze.Runner.The.Scorch.Trials.2015.DKSUBS.1080p.BluRay.x264-iRL Minority.Report.S01E05.Retail.DKsubs.720p.HDTV.x264-RAPiDCOWS Quantico.S01E04.Custom.DKsubs.720p.WEB-DL.x264-RAPiDCOWS The.Flash.2014.S02E07.Custom.DKsubs.720p.WEB-DL.x264-RAPiDCOWS The.Librarians.2014.S02E02.Custom.DKsubs.720p.HDTV.x264-RAPiDCOWS Ant.Man.2015.DKSUBS.REMUX.BluRay.1080p.AVC.DTS-HD.MA7.1-iRL The.Blacklist.S03E08.Retail.DKsubs.720p.WEBRip.H.264-RAPiDCOWS Limitless.S01E09.Custom.DKsubs.720p.HDTV.x264-NGSerier Noble.2014.Custom.DKsubs.1080p.BluRay.x264-ROYAL The.Transporter.Refueled.2015.DKSUBS.720p.BluRay.x264-iRL Ant.Man.2015.DKSUBS.1080p.BluRay.x264-iRL Hitman.Agent.47.2015.NORDiC.REMUX.BluRay.1080p.AVC.DTS-HD.MA.7.1-iRL The.Bastard.Executioner.S01E10.Retail.DKsubs.720p.WEB-DL.H.264-RAPiDCOWS Homeland.S05E07.Retail.DKsubs.720p.WEB-DL.H.264-RAPiDCOWS Everest.2015.DKSUBS.1080p.WEB-DL.h264-iRL Boulevard.2014.RETAiL.DKsubs.1080p.BluRay.x264-PUNKTUM Gotham.S02E09.Custom.DKsubs.720p.HDTV.x264-NGSerier Blindspot.S01E09.Custom.DKsubs.720p.HDTV.x264-NGSerier Arrow.S04E06.Custom.DKsubs.720p.WEB-DL.x264-RAPiDCOWS Hitman.Agent.47.2015.DKSUBS.1080p.BluRay.x264-iRL The.Walking.Dead.S06E06.Custom.DKsubs.720p.HDTV.x264-NGSerier Heist.2015.Custom.DKsubs.1080p.WEB-DL.h264-SUBLiME Steel.Dawn.1987.REMASTERED.720p.BluRay.x264-VETO Get.Santa.2014.DKsubs.720p.BluRay.x264-GenX The.Flash.2014.S02E07.Custom.DKsubs.1080p.WEB-DL.x264-RAPiDCOWS Summer.with.Monika.1953.1080p.BluRay.x264-SADPANDA Back.In.Time.2015.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS Heartbreakers.2001.1080p.BluRay.x264-SiNNERS Heartbreakers.2001.720p.BluRay.x264-SiNNERS Larry.Gaye.2015.720p.BluRay.x264-NOSCREENS Summer.Interlude.1951.1080p.BluRay.x264-SADPANDA Summer.Interlude.1951.720p.BluRay.x264-SADPANDA Eight.Men.Out.1988.1080p.BluRay.x264-SiNNERS Eight.Men.Out.1988.720p.BluRay.x264-SiNNERS Wall.Street.1987.REMASTERED.1080p.BluRay.x264-SADPANDA Wall.Street.1987.REMASTERED.720p.BluRay.x264-SADPANDA Ikiru.1952.1080p.BluRay.x264-SiNNERS Ikiru.1952.720p.BluRay.x264-SiNNERS Fairy.Tale.A.True.Story.1997.1080p.BluRay.x264-USURY Transformers.Age.of.Extinction.2014.Retail.DKsubs.REMUX.1080p.BluRay.AVC.TrueHD.Atmos7.1-RAPiDCOWS Fairy.Tale.A.True.Story.1997.720p.BluRay.x264-USURY Minions.2015.SWEDiSH.REPACK.720p.BluRay.x264-BLUEYES Bronson.2008.PROPER.1080p.BluRay.x264-SADPANDA Closely.Observed.Trains.1966.1080p.BluRay.x264-HD4U Bronson.2008.PROPER.720p.BluRay.x264-PHOBOS Closely.Observed.Trains.1966.720p.BluRay.x264-HD4U Criminal.Activities.2015.720p.WEB-DL.DD5.1.H.264-PLAYNOW.mkv Bones.S11E05.Retail.DKsubs.720p.HDTV.x264-RAPiDCOWS Steve.Jobs.The.Man.in.the.Machine.2015.Retail.DKsubs.720p.BluRay.x264-RAPiDCOWS Steve.Jobs.The.Man.in.the.Machine.2015.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS Ted.2.2015.EXTENDED.1080p.BluRay.x264-DRONES Minions.2015.SWEDiSH.720p.BluRay.x264-BLUEYES Ted.2.2015.EXTENDED.720p.BluRay.x264-DRONES Sandheden.Om.Maend.2010.DANiSH.720p.BluRay.x264-BLUEYES Best.of.Enemies.2015.DOCU.1080p.BluRay.x264-PSYCHD Best.of.Enemies.2015.DOCU.720p.BluRay.x264-PSYCHD Ant-Man.2015.3D.1080p.BluRay.x264-SPRiNTER Nosferatu.1922.REMASTERED.1080p.BluRay.x264-GHOULS 6.Ways.To.Sundown.2015.720p.BluRay.x264-PFa Cats.Eye.1985.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS The.Transporter.Refueled.2015.1080p.BluRay.x264-GECKOS Noble.2014.Custom.DKsubs.720p.BluRay.x264-ROYAL Nosferatu.1922.REMASTERED.720p.BluRay.x264-GHOULS Ant.Man.2015.DKSUBS.720p.BluRay.x264-iRL The.Transporter.Refueled.2015.720p.BluRay.x264-GECKOS All.That.Jazz.1979.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS The.Bastard.Executioner.S01E10.Retail.DKsubs.1080p.WEB-DL.H.264-RAPiDCOWS Victoria.2015.1080p.BluRay.x264-USURY The.Cabin.In.The.Woods.2012.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS Sinister.2012.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS Safe.House.2012.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS 1408.2007.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS The.Last.Airbender.2010.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS The.Rewrite.2014.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS The.Rewrite.2014.Retail.DKsubs.720p.BluRay.x264-RAPiDCOWS Maze.Runner.The.Scorch.Trials.2015.DKSUBS.720p.BluRay.x264-iRL Last.Knights.2015.Retail.DKsubs.1080p.BluRay.x264-RAPiDCOWS Last.Knights.2015.Retail.DKsubs.720p.BluRay.x264-RAPiDCOWS Maze.Runner.The.Scorch.Trials.2015.1080p.BluRay.x264-SPARKS Maze.Runner.The.Scorch.Trials.2015.720p.BluRay.x264-SPARKS Victoria.2015.720p.BluRay.x264-USURY Ant-Man.2015.1080p.BluRay.x264-SPARKS Ant-Man.2015.720p.BluRay.x264-SPARKS Pathfinder.2007.Retail.DKsubs.UNRATED.720p.BluRay.x264-RAPiDCOWS Pathfinder.2007.Retail.DKsubs.UNRATED.1080p.BluRay.x264-RAPiDCOWS 90.Minutes.In.Heaven.2015.1080p.BluRay.x264-DRONES 90.Minutes.in.Heaven.2015.720p.BluRay.x264-DRONES Everest.2015.DKSUBS.720p.WEB-DL.h264-iRL Maze.Runner.The.Scorch.Trials.2015.DKSUBS.720p.WEBRip.x264-iRL Boulevard.2014.RETAiL.DKsubs.720p.BluRay.x264-PUNKTUM The.Stanford.Prison.Experiment.2015.LIMITED.1080p.BluRay.X264-AMIABLE Wings.Of.Life.2011.DOCU.1080p.BluRay.x264-HDEX The.Stanford.Prison.Experiment.2015.LIMITED.720p.BluRay.X264-AMIABLE The.Stanford.Prison.Experiment.2015.1080p.WEB-DL.DD5.1.H264-RARBG The.33.2015.1080p.WEB-DL.DD5.1.H264-RARBG' # Print the match result str.scan(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