use strict;
my $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';
my $regex = qr/balance\"\:\"([0-9]{1,})\"\,\"settings/p;
if ( $str =~ /$regex/ ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html