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 = /(^|[^\{])(\{\{((\#invoke\:\s*)?([\w\s\:\/\-\+\.\'\"\\]+?))\s*((?:\s*\|(?:[^\|\{\}]*(?:\{\{[^\{\}]*(?:\{[^\{\}]*\{\{[^\{\}]*(?:\{(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*)\}|(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*))?\}\}\}[^\{\}]*|\{\{[^\{\}]*(?:\{(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*)\}|(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*))?\}\}[^\{\}]*)?\}\}[^\{\}]*|\{\{\{[^\{\}]*(?:\{\{(?:\{[^\{\}]+\}|[^\{\}]+)\}\}[^\{\}]*)?\}\}\}[^\{\}]*)?))*)\}\})/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('(^|[^\\{])(\\{\\{((\\#invoke\\:\\s*)?([\\w\\s\\:\\\/\\-\\+\\.\\\'\\"\\\\]+?))\\s*((?:\\s*\\|(?:[^\\|\\{\\}]*(?:\\{\\{[^\\{\\}]*(?:\\{[^\\{\\}]*\\{\\{[^\\{\\}]*(?:\\{(?:\\{\\{(?:\\{[^\\{\\}]+\\}|[^\\{\\}]+)\\}\\}[^\\{\\}]*)\\}|(?:\\{\\{(?:\\{[^\\{\\}]+\\}|[^\\{\\}]+)\\}\\}[^\\{\\}]*))?\\}\\}\\}[^\\{\\}]*|\\{\\{[^\\{\\}]*(?:\\{(?:\\{\\{(?:\\{[^\\{\\}]+\\}|[^\\{\\}]+)\\}\\}[^\\{\\}]*)\\}|(?:\\{\\{(?:\\{[^\\{\\}]+\\}|[^\\{\\}]+)\\}\\}[^\\{\\}]*))?\\}\\}[^\\{\\}]*)?\\}\\}[^\\{\\}]*|\\{\\{\\{[^\\{\\}]*(?:\\{\\{(?:\\{[^\\{\\}]+\\}|[^\\{\\}]+)\\}\\}[^\\{\\}]*)?\\}\\}\\}[^\\{\\}]*)?))*)\\}\\})', 'g') const str = `{{DISPLAYTITLE:Stats}} ====<span style="font-size:1.5em;">Example</span>==== '''Calculate ''Attack Power'' for Standard Guerilla Helmet at level 65''' <small>(its max level)</small> {{#invoke:Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Standard Guerilla Helmet|taco {{{foo}}} bar|get=iconbordersmalllevel%small%bgimage%level%max|foo={{#if:bar|a={{{stuff|a={{bell}}}}}}}|taco=bell}}<br> {{UprisingPageFooter | fo| |taco=bell}} <onlyinclude>{{#invoke:UprisingEquipmentInfobox2 |get={{{get|infobox}}} |arg1={{{arg1|}}} |arg2={{{arg2|}}} |arg3={{{arg3|}}} |image=Uprising_Icon_Item_Base_M_Backpack_00061_C.png |name=Altered Bounty Hunter Pack |description=Defensive gear used by the Ivax Syndicate. |tier=2 |baseStarLevel=3 |evolution=1 |stars=4 |maxstarcount=6 |type=backpack |location=Bespin |gearSetName=Altered Bounty Hunter |gearSetBaseName=Bounty Hunter |gearSetDisplayName=Altered Bounty Hunter |gearSetPrefix=Altered |faction=Ivax Syndicate |gearType=Defensive |baseLevel=65 |levelCap=90 |navNext=Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Revised_Bounty_Hunter_Pack/T2 |navPrev=Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Stock_Bounty_Hunter_Pack/T2 |baseStat=250 |attack=28.5% |attackMin=584 |attackBase=1471 |attackMax=2565 |armor=14.5% |armorMin=297 |armorBase=748 |armorMax=1305 |utility=57% |utilityMin=1166 |utilityBase=2941 |utilityMax=5130 |mod1Name=Control |mod1Value=+4% |mod2Name=Attack Speed |mod2Value=+3.5% |mod3Name=Accuracy |mod3Value=+2.5% |upgradeComponent1Name=Faceted Carbonite |upgradeComponent1Type=Carbonite |upgradeComponent1Prefix=Faceted |upgradeComponent1Count=3 |upgradeComponent2Name=Faceted Chunah |upgradeComponent2Type=Chunah |upgradeComponent2Prefix=Faceted |upgradeComponent2Count=3 |upgradeCost=192000 |sellPriceMin=21600 |sellPriceMax=64800 }}</onlyinclude> The '''&quot;Altered Bounty Hunter Pack&quot;''' is a piece of '''Tier 2''' armor, equippable to the ''Backpack'' slot, that appears in [[Star Wars: Uprising]]. It's a member of the ''&quot;{{#ifexist:Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/GearSets/Altered Bounty Hunter|[[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/GearSets/Altered Bounty Hunter|Altered Bounty Hunter]]|{{#ifexist:Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/GearSets/Bounty Hunter|[[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/GearSets/Bounty Hunter|Altered Bounty Hunter]]|Altered Bounty Hunter}}}}&quot;'' armor set and has been upgraded 1 time <small>(E1)</small>. ==Information== ; Known Location(s): : Bespin ; General Equation: : <pre>ceiling(max((92.30769231*PowerUpLevel+4000),(320*(PowerUpLevel-65)+10000))*ScalarValue)</pre> <!-- General information, and location(s) where the item can be seen/acquired --> ==Gallery== <gallery> Uprising_Icon_Item_Base_M_Backpack_00061_C.png Uprising_Icon_Item_Base_F_Backpack_00061_C.png </gallery> <!-- If available, show male/female versions in gallery --> ==Related== ; Variations : [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Revised_Bounty_Hunter_Pack/T2|Revised Bounty Hunter Pack]]&nbsp;<small>(Upgrades To)</small> : [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Stock_Bounty_Hunter_Pack/T2|Stock Bounty Hunter Pack]]&nbsp;<small>(Upgraded From)</small> ; Altered Bounty Hunter Set : [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Gloves/T2|Altered Bounty Hunter Gloves]]&nbsp;<small>(T2,E1)</small> : [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Helmet/T2|Altered Bounty Hunter Helmet]]&nbsp;<small>(T2,E1)</small> : [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Jacket/T2|Altered Bounty Hunter Jacket]]&nbsp;<small>(T2,E1)</small> : [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Fatigues/T2|Altered Bounty Hunter Fatigues]]&nbsp;<small>(T2,E1)</small> <!-- Items directly related to this one. Like previous/next upgraded versions and items with similar attributes. --> {{UprisingPageFooter}} `; // 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