Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • 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

const regex = /^\[([^\]]+)\].*/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('^\\[([^\\]]+)\\].*', 'gm') const str = `[ASW] Kimi wa Meido-sama - 09 [1080p HEVC x265 10Bit][AAC] [Judas] Party kara Tsuihou sareta Sono Chiyushi, Jitsu wa Saikyou ni Tsuki (The Healer Who Was [Erai-raws] Ao no Exorcist - Yuki no Hate Hen - 09 [1080p CR WEBRip HEVC EAC3][MultiSub][13D00C81] [somedroplet] Pokémon Horizons / Pocket Monsters (2023) - 075 (English names edit) [ASW] Party kara Tsuihou sareta Sono Chiyushi, Jitsu wa Saikyou ni Tsuki - 09 [1080p HEVC x265 10Bit [Raze] Ao no Exorcist - Yuki no Hate-hen - 09 x265 10bit 1080p 143.8561fps.mkv Miru Tights [English-Subs] [1080p AV1 BDRip] | OVA [Erai-raws] Chi - Chikyuu no Undou ni Tsuite - 10 [1080p][HEVC][Multiple Subtitle][57F060C1].mkv [ToonsHub] BLEACH Thousand-Year Blood War S01E31 1080p DSNP WEB-DL AAC2.0 H.264 (BLEACH: Sennen [Erai-raws] Kimi wa Meido-sama - 09 [480p CR WEB-DL AVC AAC][MultiSub][22C85EE0].mkv [Erai-raws] Kimi wa Meido-sama - 09 [720p CR WEB-DL AVC AAC][MultiSub][EFE2DE9E].mkv [Erai-raws] Kimi wa Meido-sama - 09 [1080p CR WEB-DL AVC AAC][MultiSub][E370B831].mkv You are Ms Servant S01E09 You and the Cultural Stage 1080p CR WEB-DL AAC2.0 H 264-VARYG (Kimi wa [SubsPlease] Kimi wa Meido-sama - 09 (1080p) [5BCC1CFF].mkv [SubsPlease] Kimi wa Meido-sama - 09 (720p) [19E06B10].mkv [SubsPlease] Kimi wa Meido-sama - 09 (480p) [7D70ECDB].mkv [ToonsHub] You are Ms. Servant S01E09 1080p CR WEB-DL AAC2.0 H.264 (Kimi wa Meido-sama., Multi-Subs) [ToonsHub] The Healer Who Was Banished From His Party Is in Fact the Strongest S01E09 1080p CR WEB-DL The Healer Who Was Banished From His Party Is in Fact the Strongest S01E09 Regarding the Master Who [Erai-raws] sonochiyushi - 09 [480p CR WEB-DL AVC AAC][MultiSub][7FD59FA4].mkv [Erai-raws] sonochiyushi - 09 [720p CR WEB-DL AVC AAC][MultiSub][0D07CEFE].mkv [Erai-raws] sonochiyushi - 09 [1080p CR WEB-DL AVC AAC][MultiSub][1B09C578].mkv [SubsPlease] Party kara Tsuihou sareta Sono Chiyushi, Jitsu wa Saikyou ni Tsuki - 09 (1080p) [SubsPlease] Party kara Tsuihou sareta Sono Chiyushi, Jitsu wa Saikyou ni Tsuki - 09 (720p) [F07F0D27] [SubsPlease] Party kara Tsuihou sareta Sono Chiyushi, Jitsu wa Saikyou ni Tsuki - 09 (480p) [0CF2284D] [DKB] Ao no Exorcist - S04E09 [1080p][HEVC x265 10bit][Multi-Subs][weekly] [Trix] Blue Lock S02E09 (WEB 1080p AV1 E-AC3) [Multi Subs] [1D6D323D].mkv [Erai-raws] Blue Lock vs U-20 Japan - 09 [1080p CR WEBRip HEVC EAC3][MultiSub][E9D826EE].mkv [Ai-kun] Ranma 1-2 (2024) - 09 (1080p).mkv [Judas] Ao no Exorcist (Blue Exorcist) - S04E09 [1080p][HEVC x265 10bit][Eng-Subs] (Weekly) Detective.Conan.The.Million.Dollar.Pentagram.1080p.BluRay.Opus5.1.x265-RUDY [ASW] Ao no Exorcist - Yuki no Hate-hen - 09 [1080p HEVC x265 10Bit][AAC] [Erai-raws] Bleach - Sennen Kessen Hen - Soukoku Tan - 09 [1080p][HEVC][Multiple Subtitle][4E82BE69] [DKB] Ranma ½ (2024) - S01E09 [1080p][HEVC x265 10bit][Dual-Audio][Multi-Subs][weekly] Murai.in.Love.S01.1080p.DSNP.WEB-DL.AAC2.0.H.264-VARYG [ASW] Maou 2099 - 08 [1080p HEVC x265 10Bit][AAC] Murai.in.Love.S01.1080p.DSNP.WEB-DL.AAC2.0.H.264.MULTi-VARYG [Anipakku] Yamada-kun to Lv999 no Koi wo Suru (S01) [BD 1080p x265 OPUS][PT-BR] (My Love Story with [Shroud] Mononoke The Movie - The Phantom in the Rain (1080p NF WEB AVC EAC3) [Dual-Audio] | [ToonsHub] You Are Ms. Servant S01E09 1080p MW WEB-DL AAC2.0 H.264 (Kimi wa Meido-sama., Multi-Subs) [Erai-raws] Ao no Exorcist - Yuki no Hate Hen - 09 [480p CR WEB-DL AVC AAC][MultiSub][5BE301E9].mkv [Erai-raws] Ao no Exorcist - Yuki no Hate Hen - 09 [720p CR WEB-DL AVC AAC][MultiSub][1F9D57C2].mkv [Erai-raws] Ao no Exorcist - Yuki no Hate Hen - 09 [1080p CR WEB-DL AVC AAC][MultiSub][C3D27668].mkv [ToonsHub] Blue Exorcist S04E09 1080p CR WEB-DL AAC2.0 H.264 (Ao no Exorcist, Multi-Subs) The Healer who was Banished from his Party is in fact the Strongest S01E09 That Master is Actually a [SubsPlease] Ao no Exorcist - Yuki no Hate-hen - 09 (1080p) [DD964884].mkv Blue Exorcist S04E09 Congratulations 1080p CR WEB-DL AAC2.0 H 264-VARYG (Ao no Exorcist, Multi-Subs) [SubsPlease] Ao no Exorcist - Yuki no Hate-hen - 09 (480p) [D66A10B8].mkv [SubsPlease] Ao no Exorcist - Yuki no Hate-hen - 09 (720p) [78470FFE].mkv [ToonsHub] The Healer who was Banished from his Party is in fact the Strongest S01E09 2160p B-Global [ASW] Blue Lock - 33 [1080p HEVC x265 10Bit][AAC] [ToonsHub] The Healer who was Banished from his Party is in fact the Strongest S01E09 1080p B-Global [ToonsHub] The Healer who was Banished from his Party is in fact the Strongest S01E09 1080p B-Global [Anon] TOHAI - Ura Rate Mahjong Touhai Roku - 09 [1080p AMZN] [Judas] Bleach - Thousand Year Blood War - S17E35 [1080p][HEVC x265 10bit][Multi-Subs] (Weekly) [ASW] Bleach Thousand-Year Blood War - 35 [1080p HEVC x265 10Bit][AAC] [DKB] Maou-sama, Retry! R - S02E10 [1080p][HEVC x265 10bit][Multi-Subs][weekly] [ToonsHub] DEMON LORD 2099 S01E08 1080p CR WEB-DL AAC2.0 H.264 (Maou 2099, Multi-Subs) DEMON LORD 2099 S01E08 Cybermagic City Akihabara 1080p CR WEB-DL AAC2.0 H 264-VARYG (Maou 2099, [Erai-raws] Maou 2099 - 08 [480p CR WEB-DL AVC AAC][MultiSub][59075CC4].mkv [SubsPlease] Maou 2099 - 08 (1080p) [053F06A3].mkv [Erai-raws] Maou 2099 - 08 [720p CR WEB-DL AVC AAC][MultiSub][9631E907].mkv [Erai-raws] Maou 2099 - 08 [1080p CR WEB-DL AVC AAC][MultiSub][180240AD].mkv [SubsPlease] Maou 2099 - 08 (480p) [313FE600].mkv [SubsPlease] Maou 2099 - 08 (720p) [F572E0D2].mkv Ranma ½ - 09 | Ranma ½ (2024) [English Dub][1080p] [DKB] Chi. Chikyuu no Undou ni Tsuite - S01E10 [1080p][HEVC x265 10bit][Multi-Subs][weekly] [Anipakku] Kaii to Otome to Kamikakushi (S01) [BD 1080p x265 OPUS][PT-BR] (Mysterious Disappearances I The Thieves of Color Paints (Похитители красок) (1959) [ARR].mp4 Yakumo Tatsu OVA 01-02 [Kingmenu] Meisou-Ou Border OVA [Kingmenu].mp4 [DKB] Bleach - Sennen Kessen-hen - 35 [1080p][HEVC x265 10bit][Multi-Subs][weekly] [Erai-raws] Ranma 1_2 (2024) - 09 [720p][Multiple Subtitle][A8B0A90A].mkv [Erai-raws] Ranma 1_2 (2024) - 09 [1080p][Multiple Subtitle][9F90633A].mkv [ToonsHub] BLUE LOCK S02E09 1080p CR WEB-DL AAC2.0 H.264 (Multi-Subs) [Sav1or] Uma Musume: Pretty Derby Seasons S1 + S2 + S3 + OVA [BD][1080p][AV1][OPUS] (Umamusume) [SavI0r] Classroom☆Crisis Complete [BD][1080p][AV1][OPUS] [Kosaka&Sav1or] Shikanoko Nokonoko Koshitantan (WEB) (My Deer Friend Nokotan) (1080p AV1 10Bit OPUS) [MultiAudio] [MultiSubs] [NeoLX] Bleach - Sennen Kessen Hen (千年血戦篇) - Soukoku Tan (相剋譚) - 08 [1080p x264 10bits AAC][Multiple Subtitles].mkv [NeoLX] Solo Leveling - S01E09 [1080p x264 10bits AAC][Multiple Subtitles].mkv [DmonHiro x VCB-Studio] Kemurikusa / ケムリクサ 10-bit 1080p HEVC BDRip [English](Unofficial) [Nekomoe kissaten&VCB-Studio] ODDTAXI 10-bit 1080p HEVC BDRip [Fin] Some Title - S99E103 - Some Episode Title (SSD 8192p VVC) -GroupName`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions