use strict;
my $str = 'Work
Work
Fire
Global{"dmids":[200000298206588]}
{"dmids":[200000298207769,200000315647883]}
{"dmids":[200000298207847,200000298559762,200000298729095,200000298937045,200000299376139,200000337459486,200000339993204,2000000298149778]}
{"dmids":[200000298208329,200000298316016,200000298560524,200000300915842,2000000298179810,2000000298180861]}
{"dmids":[200000298208335,200000298316025,200000298560517,200000300915858,2000000298179808,2000000298180858]}
{"dmids":[200000298208343,200000298316014,200000298560521,200000300915848,2000000298179798,2000000298180857]}
{"dmids":[200000298210597,200000299898455,200000299949910,200000304060818,200000305323250,2000000298190262]}';
my $regex = qr/^(.)/mp;
if ( $str =~ /$regex/g ) {
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