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[^\\{\\}]*)?\\}\\}\\}[^\\{\\}]*)?))*)\\}\\})', '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 '''"Altered Bounty Hunter Pack"''' is a piece of '''Tier 2''' armor, equippable to the ''Backpack'' slot, that appears in [[Star Wars: Uprising]]. It's a member of the ''"{{#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}}}}"'' 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]] <small>(Upgrades To)</small>
: [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Stock_Bounty_Hunter_Pack/T2|Stock Bounty Hunter Pack]] <small>(Upgraded From)</small>
; Altered Bounty Hunter Set
: [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Gloves/T2|Altered Bounty Hunter Gloves]] <small>(T2,E1)</small>
: [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Helmet/T2|Altered Bounty Hunter Helmet]] <small>(T2,E1)</small>
: [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Jacket/T2|Altered Bounty Hunter Jacket]] <small>(T2,E1)</small>
: [[Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Equipment/Altered_Bounty_Hunter_Fatigues/T2|Altered Bounty Hunter Fatigues]] <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