const regex = /{\{learnlist.+\d\}\}/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('{\\{learnlist.+\\d\\}\\}', 'g')
const str = `====By {{pkmn|breeding}}====
{{learnlist/breedh/6|Aipom|Normal|Normal|2|xy=n}}
{{learnlist/breed6|{{MSP|025|Pikachu}}{{MSP|058|Growlithe}}{{MSP|077|Ponyta}}{{MSP|078|Rapidash}}{{MSP|083|Farfetch'd}}{{MSP|135|Jolteon}}<br>{{MSP|190|Aipom}}{{MSP|424|Ambipom}}{{MSP|203|Girafarig}}{{MSP|215|Sneasel}}{{MSP|418|Buizel}}{{MSP|419|Floatzel}}<br>{{MSP|427|Buneary}}{{MSP|428|Lopunny}}{{MSP|522|Blitzle}}{{MSP|523|Zebstrika}}{{MSP|570|Zorua}}{{MSP|571|Zoroark}}<br>{{MSP|587|Emolga}}{{MSP|659|Bunnelby}}{{MSP|660|Diggersby}}|Agility|Psychic|Status|—|—|30|||Cool|3|0}}
{{learnlist/breed6|{{MSP|077|Ponyta}}{{MSP|078|Rapidash}}{{MSP|320|Wailmer}}{{MSP|321|Wailord}}{{MSP|325|Spoink}}{{MSP|326|Grumpig}}<br>{{MSP|427|Buneary}}{{MSP|428|Lopunny}}{{MSP|619|Mienfoo}}{{MSP|620|Mienshao}}{{MSP|659|Bunnelby}}{{MSP|660|Diggersby}}|Bounce|Flying|Physical|85|85|5|||Cute|1|0}}
{{learnlist/breed6|{{MSP|287|Slakoth}}{{MSP|288|Vigoroth}}{{MSP|289|Slaking}}{{MSP|448|Lucario}}|Counter|Fighting|Physical|—|100|20|||Tough|2|0}}
{{learnlist/breed6|{{MSP|056|Mankey}}{{MSP|133|Eevee}}{{MSP|216|Teddiursa}}{{MSP|217|Ursaring}}{{MSP|263|Zigzagoon}}{{MSP|264|Linoone}}<br>{{MSP|287|Slakoth}}{{MSP|289|Slaking}}{{MSP|300|Skitty}}{{MSP|677|Espurr}}{{MSP|678|Meowstic}}|Covet|Normal|Physical|60|100|25||'''|Cute|1|0}}
{{learnlist/breed6|{{MSP|300|Skitty}}{{MSP|301|Delcatty}}{{MSP|572|Minccino}}{{MSP|619|Mienfoo}}{{MSP|620|Mienshao}}{{MSP|659|Bunnelby}}|Double Slap|Normal|Physical|15|85|10||'''|Cute|1|0}}
{{learnlist/breed6|{{MSP|052|Meowth}}{{MSP|053|Persian}}{{MSP|274|Nuzleaf}}{{MSP|300|Skitty}}{{MSP|301|Delcatty}}{{MSP|431|Glameow}}<br>{{MSP|432|Purugly}}{{MSP|509|Purrloin}}{{MSP|510|Liepard}}{{MSP|619|Mienfoo}}{{MSP|620|Mienshao}}{{MSP|677|Espurr}}<br>{{MSP|678|Meowstic}}|Fake Out|Normal|Physical|40|100|10||'''|Cute|2|3}}
{{learnlist/breed6|{{MSP|019|Rattata}}{{MSP|020|Raticate}}{{MSP|128|Tauros}}{{MSP|197|Umbreon}}{{MSP|206|Dunsparce}}{{MSP|335|Zangoose}}<br>{{MSP|359|Absol}}{{MSP|418|Buizel}}{{MSP|419|Floatzel}}{{MSP|509|Purrloin}}{{MSP|510|Liepard}}{{MSP|522|Blitzle}}<br>{{MSP|523|Zebstrika}}{{MSP|570|Zorua}}{{MSP|571|Zoroark}}{{MSP|587|Emolga}}{{MSP|626|Bouffalant}}|Pursuit|Dark|Physical|40|100|20|||Clever|2|1}}
{{learnlist/breed6|{{MSP|448|Lucario}}{{MSP|619|Mienfoo}}{{MSP|678|Meowstic}}|Quick Guard|Fighting|Status|—|—|15|||Cool|2|0}}
{{learnlist/breed6|{{MSP|335|Zangoose}}{{MSP|461|Weavile}}{{MSP|501|Oshawott}}{{MSP|502|Dewott}}{{MSP|503|Samurott}}{{MSP|626|Bouffalant}}|Revenge|Fighting|Physical|60|100|10|||Tough|2|0}}
{{learnlist/breed6|{{MSP|023|Ekans}}{{MSP|024|Arbok}}{{MSP|052|Meowth}}{{MSP|053|Persian}}{{MSP|054|Psyduck}}{{MSP|055|Golduck}}<br>{{MSP|056|Mankey}}{{MSP|057|Primeape}}{{MSP|190|Aipom}}{{MSP|424|Ambipom}}{{MSP|197|Umbreon}}{{MSP|206|Dunsparce}}<br>{{MSP|215|Sneasel}}{{MSP|461|Weavile}}{{MSP|293|Whismur}}{{MSP|294|Loudred}}{{MSP|295|Exploud}}{{MSP|336|Seviper}}<br>{{MSP|352|Kecleon}}{{MSP|434|Stunky}}{{MSP|435|Skuntank}}|Screech|Normal|Status|—|85|40|||Clever|3|0}}
{{learnlist/breed6|{{MSP|025|Pikachu}}{{MSP|161|Sentret}}{{MSP|162|Furret}}{{MSP|194|Wooper}}{{MSP|195|Quagsire}}{{MSP|231|Phanpy}}<br>{{MSP|232|Donphan}}{{MSP|495|Snivy}}{{MSP|496|Servine}}{{MSP|497|Serperior}}{{MSP|504|Patrat}}{{MSP|505|Watchog}}<br>{{MSP|572|Minccino}}|Slam|Normal|Physical|80|75|20||'''|Tough|4|0}}
{{learnlist/breed6|{{MSP|206|Dunsparce}}|Spite|Ghost|Status|—|100|10|||Tough|2|1}}
{{learnlist/breed6|{{MSP|053|Persian}}{{MSP|264|Linoone}}{{MSP|655|Delphox}}|Switcheroo|Dark|Status|—|100|10|||Clever|2|1}}
{{learnlist/breedf/6|Aipom|Normal|Normal|2}}
`;
// 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