const regex = /balance\"\:\"([0-9]{1,})\"\,\"settings/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('balance\\"\\:\\"([0-9]{1,})\\"\\,\\"settings', '')
const str = `[200,{"cookie":"623218:b4693930b241d92abcd866afd3a48090ee213570","user":{"id":"623218","name":"null","email":"knight-war@hotmail.com","api_key":"09cafaaa34299398474bb6bdff7e02a2a7fb6fda","premium":"Thu Oct 09 2014 17:39:15 GMT+0000 (UTC)","premium_unix":"1412876355","webspace":53687091200,"traffic":{"current":1099511627776,"increase":0,"last":1413569003,"max":0},"balance":"0","settings":{},"external_id":"null","ftp_username":"ftp623218","partner":"3","partner_last":"1413025653","allow_dupe_names":"0"},"session":"45af19f7-4d90-40ad-b90e-d98fa22ba15c"}]1`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions