How to get the content in [] ()

A paragraph, such as

[aaa](bbb(ASDASD)XSSAXASX)

what I want to get is bbb (ASDASD) XSSAXASX


javascript regularities cannot do nested matching. If you really want to do so, you can write a function to implement it. In your case, you can use a stack mechanism


[xxxx] (asdasdasd () asdasdasdasd) because it is parsed in md format. What I want is asdasdasd () asdasdasdasd


/(?<=\().*(?=\))/

try this and see if it's the result you want


this problem is described. Others need to guess what the data and results you are dealing with



function nestMatch($str)
{
    let map = {
        'text' : []
        ,'match' : []
    };
    $str.replace(/(\(|\))([^\(\)]*)/g, function($match, $tag, $text){
        let text = '';
        switch($tag)
        {
            case '(':
                map.text.unshift($text);
                break;
            case ')':
                if(map.text.length > 0)
                {
                    text = '(' + map.text.shift() + ')';
                    if(map.text.length <= 0)
                        map.text[0] = '';

                    map.text[0] = map.text[0] + text + $text;
                    map.match.push(text);
                }
                break;
        }

        return $match;
    });

    return map.match;
}
console.log(nestMatch('111(aaa(bbb)ccc)222(ddd(eee)fff(ggg)hhh)333'));

output ["(bbb)", "(aaa (bbb) ccc)", "(eee)", "(ggg)", "(ddd (eee) fff (ggg) hhh)]

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9816f-16ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9816f-16ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?