JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = 'Array(    [shopUsername] => tod\n    [password] => 12345678\n    [shopID] => 19)';
var match;
var results = [];
var regex = new RegExp(/\[(.*)\]/g);
while(match = regex.exec(str)) {
    results.push(match[1]);
}
console.log(results);