Get the contents of the double $curly braces in the string

I want to match

$${}$$
Content in

str is complicated. As follows, I want to find out the contents of all the double $$curly braces and put them into an array. What should I do?

[{"field_id":"DM0002","field":"$${gender}$$","weight":"0.5","data_type":"1","condition_scores":[{"condition":{"type":"and","options":[{"option":"gt","value":"$${gender}$$","type":"word"},{"option":"gte","value":"$${userName}$$","data_type":"","type":"word","field_id":"","filed":""}]},"score":"50"},{"condition":{"type":"and","options":[{"option":"gt","value":"$${gender}$$","data_type":"","type":"word","field_id":"","filed":""},{"option":"lt","value":"$${gender}$$","data_type":"","type":"word","field_id":"","filed":""}]},"score":"80"}]}]

JSON is as follows

[
    {
        "field_id":"DM0002",
        "field":"$${gender}$$",
        "weight":"0.5",
        "data_type":"1",
        "condition_scores":[
            {
                "condition":{
                    "type":"and",
                    "options":[
                        {
                            "option":"gt",
                            "value":"$${gender}$$",
                            "type":"word"
                        },
                        {
                            "option":"gte",
                            "value":"$${userName}$$",
                            "data_type":"",
                            "type":"word",
                            "field_id":"",
                            "filed":""
                        }
                    ]
                },
                "score":"50"
            },
            {
                "condition":{
                    "type":"and",
                    "options":[
                        {
                            "option":"gt",
                            "value":"$${gender}$$",
                            "data_type":"",
                            "type":"word",
                            "field_id":"",
                            "filed":""
                        },
                        {
                            "option":"lt",
                            "value":"$${gender}$$",
                            "data_type":"",
                            "type":"word",
                            "field_id":"",
                            "filed":""
                        }
                    ]
                },
                "score":"80"
            }
        ]
    }
]

try to use

yourself.
/^\$\$\{(\w{1,10})\}\$\$$/.exec("$${4555}$$222$${4555555788}$$")

match is not successful, find the solution


var str = '[{"field_id":"DM0002","field":"$${gender}$$","weight":"0.5","data_type":"1","condition_scores":[{"condition":{"type":"and","options":[{"option":"gt","value":"$${gender}$$","type":"word"},{"option":"gte","value":"$${userName}$$","data_type":"","type":"word","field_id":"","filed":""}]},"score":"50"},{"condition":{"type":"and","options":[{"option":"gt","value":"$${gender}$$","data_type":"","type":"word","field_id":"","filed":""},{"option":"lt","value":"$${gender}$$","data_type":"","type":"word","field_id":"","filed":""}]},"score":"80"}]}]'
var reg = /\$\$\{(\w+)\}\$\$/g;
var result = str.match(reg).map(item => item.replace(reg,'$1'));
console.log(result);

OR

var result = [];
var r = ''
do
{
    r = reg.exec(str);
    r && result.push(r[1]);
}
while (r !== null) 

/\$\$\{(\w{1,10})\}\$\$/.exec('$${4555}$$222$${4555555788}$$')

or

/^\$\$\{(\w+)\}\$\$$/.exec('$${4555}$$222$${4555555788}$$')
Menu