MZ Javascript RegEx: how to utilize named capture groups

As you probably noticed from my other threads, i am currently working at a Plugin and i actually make good progress. Now I want to utilize the named capture groups, because of how it makes it easier to extract the information I need from the notetag.
Unfortunately, i wasn't able to find out how to get the "group" object of the objects I got from the Iterator from matchAll(). So my question would be how to analyze the content of a named capture group in JavaScript.

The for this part relevant Code is:
```
Code:
const regex1new = /(?<ItemCategory>Item|Armor|Weapon)\s*:\s*(?<ID>\d+)\s*(?<Weight>w:(?<WeightFactor>\d+))?/gm;


let foundTagEntrysList = Array.from(this.enemy().meta.HellsCommonDropList.matchAll(regex1new), entry => entry[0]); //If you wanna reproduce this, just replace this.enemy().meta.HellsCommonDropList with a string


newTagsAnalyser();


function newTagsAnalyser() {

        foundTagEntrysList.forEach(matchedElement => {

         

                let Item;

                let Weight;

                let ID = matchedElement.groups.ID;

                    switch (matchedElement.groups.ItemCategory) {

                        case "Item":

                            Item = $dataItems[ID];

                            break;


                        case "Weapon":

                            Item = $dataWeapon[ID];

                            break;


                        case "Armor":

                            Item = $dataArmor[ID];

                            break;

                        default:

                            break;

                    }

                    if (typeof matchedElement.groups.Weight !== 'undefined'){

                        Weight = matchedElement.groups.WeightFactor;

                    }

                commonItemDataMap.set(Item, Weight);


         

        });

    }

```
What did i expected?
That the matechedElement.group.xxx returns the content of the group that is named xxx.

What was the result?
rmmz_managers.js:2032 TypeError: Cannot read property 'ID' of undefined

P.s asked that thing already on stackoverflow, 2 minutes later it was deleted because allegedly the same as other questions, but they simply hadn't the answer i needed. Most of them didn't showed how to use it with match all, which is the thing i need.
Just a quick, non-answering note, you should get in the habit of putting your code into the forum CODE tags (the </> on the edit bar).

Everything you've posted has lost its indentation and there's a place where characters have been replaced by an emoji.

It also wreaks havoc when you make loops because [i] gets turned into italics the first time and disregarded after.
In case it helps, there's an example here regarding capture groups:
In case it helps, there's an example here regarding capture groups:
The problem was that the most explanations for named capture groups did only cover this with exec(), not matchAll(). The thing is that there is a special object for that called groups, which is supposed to allow me a really easy access to the string inside that group (matchedElement.groups.ID), but I simply struggle to find out where that object exactly is or how I have to get it. Especially since the iterator of matchAll seems to be a specialized version which only returns strings.
Look into the line where you convert the matches to an array of strings
Look into the line where you convert the matches to an array of strings
I have to admit that in the moment where I made the array.from() the first time, I wasnt sure why I needed a lambda expression if I just wanna put every iterated object into it. Will look into it today.
What irritated me a bit about that, however, was that the iterator seems to be specialized to return strings, which made me assume that I need a different kind of iterator if I really wanna have this group object. I guess I need to directly use the iterator from matchAll instead of putting it into an array first

Original thread: https://forums.rpgmakerweb.com/threads/javascript-regex-how-to-utilize-named-capture-groups.153967/