Imagine a text like in this example:
some unimportant content
some unimportant content [["string1",1,2,5,"string2"]] some unimportant content
some unimportant content
I need a REGEX pattern which will match the parts in [[ ]] and I need to match each part individually separated by commas.
I already tried
const regex = /\[\[(([^,]*),?)*\]\]/g
const found = result.match(regex)
but it doesn't work as expected. It matches only the full string and have no group matches. Also it has a catastrophic backtracking according to regex101.com if the sample text is larger.
Output should be a JS array ["string1", 1, 2, 5, "string2"]
Thank you for your suggestions.
text.match(/(?<=\[)(\[.*?])(?=])/g).map(JSON.parse)