I need to make the following extraction from string in JS:
'Sdfg dfg ldfgh (abc)' => ['abc']
'Sdfg dfg ldfgh (abc) ' => ['abc']
'Sdfg dfg ldfgh (abc) (cde)' => ['abc','cde']
'Sdfg dfg ldfgh (abc)(cde) (efgh)' => ['abc', 'cde', 'efgh']
I need to extract 'tags' in brackets, they may have spaces between them and also the whole string could have space in the end.
I've tried something like /(\(.*\))(\s?\(.*\))+/
, but it's not enough to collect all the tags. How can I extract all I need having these optional spaces between and after tags?