JSFiddle - React, Tailwind, and code Playground

JavaScript

var s = "pass[1][2011-08-21][total_passes]";
var matches = [];

s.replace(/\[(.*?)\]/g, function(g0,g1){matches.push(g1);})

alert(matches);