Regular Expressions 101

Save & Manage Regex

  • Current Version: 3
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
Processing...

Test String

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "^(?<title>(?![(\\[]).+?)((\\W|_))(\\(?\\b(?<edition>(((Recut.|Extended.|Ultimate.)?(Director.?s|Collector.?s|Theatrical|Ultimate|Extended|Despecialized|(Special|Rouge|Final|Assembly|Imperial|Diamond|Signature|Hunter|Rekall)(?=(.(Cut|Edition|Version)))|\\d{2,3}(th)?.Anniversary)(?:.(Cut|Edition|Version))?(.(Extended|Uncensored|Remastered|Unrated|Uncut|IMAX|Fan.?Edit))?|((Uncensored|Remastered|Unrated|Uncut|IMAX|Fan.?Edit|Restored|((2|3|4)in1))))))\\b\\)?.{1,3})?(?:(?<!(19|20)\\d{2}.*?|((The([-_. ]Good)?)|La|Aleksei)[-_. ])(German|French|TrueFrench))(?!.*?(German|French|TrueFrench|[-_. ].+?(19|20)\\d{2}))[-_. ](?=((19|20)\\d{2}|$|(DL|BluRay|WEB|WebHD|WebRip|720p|1080p|2160p|E?AC3D?|Subbed|DTS(-HD)?|COMPLETE|DVDR|HDTV|HDTVRip|PAL|DVD9|ML|MULTi|READNFO|UHD|BDRIP|DOKU|DD|SUBBED|DUBBED|DV|INTERNAL|iNT|BDRiP|HEVC|AVC|3D|DVD|S?VCD|DVDRiP|TS|LD|CAM|\\(?\\b(?<edition2>(((Recut.|Extended.|Ultimate.)?(Director.?s|Collector.?s|Theatrical|Ultimate|Extended|Despecialized|(Special|Rouge|Final|Assembly|Imperial|Diamond|Signature|Hunter|Rekall)(?=(.(Cut|Edition|Version)))|\\d{2,3}(th)?.Anniversary)(?:.(Cut|Edition|Version))?(.(Extended|Uncensored|Remastered|Unrated|Uncut|IMAX|Fan.?Edit))?|((Uncensored|Remastered|Unrated|Uncut|IMAX|Fan.?Edit|Restored|((2|3|4)in1))))))\\b\\)?)))(?<year>(19|20)\\d{2})?(.*?)(\\W+|_|$)(?!\\\\)"; final String string = "//Tests From Github PR\n" + "211.2018.MULTi.TRUEFRENCH.1080p.BluRay.DTS-HDMA.x264-EXTREME\n" + "8mm.1999.CUSTOM.MULTi.TRUEFRENCH.1080p.BluRay.x264-YOP\n" + "8mm.1999.CUSTOM.MULTi.TRUEFRENCH.1080p.BluRay.x264-YOP\n" + "A.Coeur.Vaillant.Rien.D.Impossible.1991.TRUEFRENCH.1080p.HDTV.AC3.X264-QWERTZ\n" + "A.Quiet.Place.Part.11.2020.TRUEFRENCH.720p.BluRay.x264.AC3-EXTREME\n" + "A.Walk.ToRemember.2002.CUSTOM.MULTi.TRUEFRENCH.1080p.BluRay.x264-DELICIOUS\n" + "A.Walk.To.Remember.2002.CUSTOM.MULTi.TRUEFRENCH.1080p.BluRay.x264-DELICIOUS\n" + "About.Adam.2001.TRUEFRENCH.1080p.AMZN.WEB-DL.H264-BOLTON08\n" + "Acusada.2019.MULTi.TRUEFRENCH.1080p.WEB-DL.H264.AC3-STVFRV\n" + "Acusada2019.TRUEFRENCH.HDRiP.x264.AC3-STVFRV\n" + "Addams.Family.Values.1993.CUSTOM.MULTi.TRUEFRENCH.1080p.BluRay.REMUX.AVC.VFF.AC3.2.0.VO.DTS-HDMA.5.1-Goldenyann\n" + "After.We.Collided.2020.TRUEFRENCH.720p.BluRay.x264-UTT\n" + "After.We.Fell.2021.MULTi.TRUEFRENCH.1080p.BluRay.DTS.x264-UTT\n" + "After.We.Fell.2021.MULTi.TRUEFRENCH.1080p.BluRay.x264-UTT\n" + "After.We.Fell.2021.MULTi.TRUEFRENCH.1080p.HDLight.x264.AC3-EXTREME\n" + "After.We.Fell.2021.MULTi.TRUEFRENCH.1080p.WEB.H264-EXTREME\n\n" + "Dune.Part.One.2021.TRUEFRENCH.BDRip.x264-Ulysse\n" + "Dune.Part.One.2021.TRUEFRENCH.720p.BluRay.x264-Ulysse\n" + "Dune.Part.One.2021.MULTI.TRUEFRENCH.1080p.BluRay.x264-Ulysse\n" + "Dune.Part.One.2021.MULTI.TRUEFRENCH.2160p.UHD.BluRay.x265-SESKAPILE\n" + "F9.The.Fast.Saga.2021.DC.TRUEFRENCH.BDRip.x264-Ulysse\n" + "F9.The.Fast.Saga.2021.DC.MULTi.TRUEFRENCH.1080p.BluRay.x264-Ulysse\n" + "F9.The.Fast.Saga.2021.DC.TRUEFRENCH.720p.BluRay.x264-Ulysse\n" + "Hitmans.Wifes.Bodyguard.2021.EXTENDED.TRUEFRENCH.720p.BluRay.x264-Ulysse\n" + "Hitmans.Wifes.Bodyguard.2021.EXTENDED.TRUEFRENCH.BDRip.x264-Ulysse,\n" + "Hitmans.Wifes.Bodyguard.2021.EXTENDED.MULTI.TRUEFRENCH.1080p.BluRay.x264-Ulysse,\n" + "Spirit.Untamed.2021.TRUEFRENCH.BDRip.x264-Ulysse\n" + "Spirit.Untamed.2021.TRUEFRENCH.720p.BluRay.x264-Ulysse\n" + "Spirit.Untamed.2021.MULTI.TRUEFRENCH.1080p.BluRay.x264-Ulysse\n" + "Space.Jam.A.New.Legacy.2021.MULTI.TRUEFRENCH.2160p.UHD.BluRay.x265-SESKAPILE\n" + "Space.Jam.A.New.Legacy2021.TRUEFRENCH.BDRip.x264-Ulysse\n" + "Space.Jam.A.New.Legacy.2021.MULTi.TRUEFRENCH.1080p.BluRay.x264-Ulysse\n" + "Space.Jam.A.New.Legacy.2021.TRUEFRENCH.720p.BluRay.x264-Ulysse\n\n" + "//Match without YEAR but with edition\n" + "Der.Movie.Eine.Unerwartete.Reise.Extended.German.720p.BluRay.x264-EXQUiSiTE\n" + "Die.Unfassbaren.Movie.Name.EXTENDED.German.DTS.720p.BluRay.x264-RHD\n" + "Die Unfassbaren Movie Name EXTENDED German DTS 720p BluRay x264-RHD\n" + "Das.A.Team.Der.Film.Extended.Cut.German.720p.BluRay.x264-ANCIENT\n\n" + "//Match without YEAR\n" + "Movie.Weg.des.Kriegers.German.720p.BluRay.x264-EXQUiSiTE\n" + "Movie.Weg.des.Kriegers.German.Extended.720p.BluRay.x264-EXQUiSiTE //Match when followed by edition\n" + "Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO\n" + "Cars.2.German.DL.720p.BluRay.x264-EmpireHD\n" + "The.German.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "Cars.2.german.CAM.720p.BluRay.x264-EmpireHD\n" + "Appaloosa.TRUEFRENCH.DVDRiP.XViD-UNSKiLLED\n" + "Arthur.Weihnachtsmann.German.DL.1080p.BluRay.x264-SONS\n" + "Arthur.Weihnachtsmann.German.AC3.BDRiP.XViD-SONS\n" + "The.German.Cam.German.720p.HDTV.x264-TVP\n\n" + "//Match with YEAR\n" + "The.Good.German.German.2006.DVDRiP.SVCD-ATS\n" + "Herman.the.German.GERMAN.2019.720p.BluRay.x264-UNiVERSUM\n" + "Der.Film.deines.Lebens.German.2011.PAL.DVDR-ETM\n" + "Joe.Bell.German.2020.AC3.BDRiP.x264-ROCKEFELLER\n" + "The.CaM.MAN.German.2006.720p.HDTV.x264-TVP\n" + "The.German.Cam.German.2006.720p.HDTV.x264-TVP\n" + "The.Good.German.German.2006.DVDRiP.SVCD-ATS //TODO It should match the year here\n" + "Deadlock.German.2021.AC3.BDRiP.x264-ROCKEFELLER\n\n" + "//TEST TRUEFRENCH\n" + "10x10.2018.MULTi.TRUEFRENCH.1080p.BluRay.x264-LOST\n" + "10x10.2018.TRUEFRENCH.720p.BluRay.x264-LOST\n" + "10x10.2018.TRUEFRENCH.BDRip.x264-PRiDEHD\n" + "12.Rounds.2009.MULTi.WiTH.TRUEFRENCH.1080p.BluRay.x264-MUxHD\n" + "12.Rounds.2009.TRUEFRENCH.720p.BluRay.x264-MUxHD\n" + "12.Rounds.TRUEFRENCH.DVDRip.XviD-REVOLTE\n" + "12.Years.a.Slave.2013.MULTi.TRUEFRENCH.1080p.BluRay.x264-FiDELiO\n" + "12.Years.a.Slave.2013.TRUEFRENCH.720p.BluRay.x264-FiDELiO\n" + "12.Years.a.Slave.2013.TRUEFRENCH.BDRip.x264-LOFiDEL\n" + "127.Hours.MULTi.WiTH.TRUEFRENCH.1080p.BluRay.x264.DTS-LOST\n" + "127.Hours.TRUEFRENCH.720p.BluRay.x264.DTS-LOST\n" + "127.Hours.TRUEFRENCH.BDRip.XviD-AYMO\n" + "A.Christmas.Carol.TRUEFRENCH.DVDRip.XviD-REVOLTE\n" + "Angels.And.Demons.EXTENDED.TRUEFRENCH.720p.BluRay.x264.DTS-UKDHD\n" + "Appaloosa.TRUEFRENCH.DVDRiP.XViD-UNSKiLLED\n" + "Arthur.Et.La.Vengeance.De.Maltazard.DVDRiP.TRUEFRENCH.XViD-FUCK\n" + "Astro.Boy.TRUEFRENCH.DVDRip.XviD-AYMO\n" + "Australia.TRUEFRENCH.DVDRip.XviD-UNSKiLLED\n" + "Black.Swan.DiRFiX.TRUEFRENCH.720p.BluRay.x264.DTS-LOST\n\n" + "//SHOULD NOT MATCH\n" + "Its.a.German.Bluray.2013.AC3.DVDRiP.x264-ETM //This should not match when scene word is followed after a year\n" + "Its.a.German.Cam.girl.2013.AC3.DVDRiP.x264-ETM //This should not match when scene word is followed after a year\n" + "The.German.Cam.2012.720p.HDTV.x264-TVP\n" + "The.German.2012.720p.HDTV.x264-TVP\n" + "German.Song.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n\n" + "German.Lancers.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "German.Lancers.2019.720p.BluRay.x264-UNiVERSUM\n" + "German.Lancers.720p.BluRay.x264-UNiVERSUM\n\n" + "German.Lessons.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "German.Fighters.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "German.Fried.Movie.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "My.German.Boyfriend.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "German.Grusel.-.Die.Edgar.Wallace-Serie.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "German.Jets.and.Destroyers.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "Tülay.German:.Kor.ve.Ateş.Yılları.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n\n" + "The.German.Doctor.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n\n" + "Movie.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc //Should not match\n" + "Movie.and.Movie.2010.Extended.Cut.German.DTS.DL.720p.BluRay.x264-HDS //Should not match\n" + "Gaia.Gruene.Hoelle.2021.German.DL.1080p.BluRay.AVC-UNTAVC //Should not match\n" + "Gaia.Gruene.Hoelle.German.2021.German.DL.1080p.BluRay.AVC-UNTAVC //Should not match\n" + "Movie.Klasse.von.1999.1990.German.720p.HDTV.x264-NORETAiL\n\n" + "La.French.2014.PL.iNT.DVDRiP.x264-N0L\n" + "La.French.2014.FRENCH.DVDRip.x264-PHoQUE\n" + "La.French.2014.PAL.FRENCH.DVDR-Ryotox\n" + "The.Good.German.2006.GERMAN.720p.HDTV.x264-TVP\n" + "Wakolda.German.Subbed.2013.AC3.DVDRiP.x264-ETM //TODO This is bullshit with subbed, don't bother\n" + "The.German.Doctor.2013.LIMITED.DVDRip.x264-RedBlade\n" + "The.Good.German.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "The.Good.German.2019.720p.BluRay.x264-UNiVERSUM\n" + "Herman.the.German.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "Herman.the.German.2019.720p.BluRay.x264-UNiVERSUM\n" + "Aleksei.German.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "Aleksei.German.2019.720p.BluRay.x264-UNiVERSUM\n" + "The.German.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n" + "The.German.2019.720p.BluRay.x264-UNiVERSUM\n" + "Der.Movie.Eine.Unerwartete.Reise.Extended.2020.German.720p.BluRay.x264-EXQUiSiTE //should not parse\n" + "The.Good.German.-.In.den.Ruinen.von.Berlin.2019.GERMAN.720p.BluRay.x264-UNiVERSUM\n"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html