use strict;
my $str = '// Somes code
$done[\'rules\'] = TRUE;
<<<<<<< HEAD
$conf[\'some_unit_id\'] = \'4-qw-gg-ds-sometext\';
=======
// Some Snippets Site Info
$conf[\'site_info\'] = array(
\'customer_service_phone\' => \'+1 323223232
\'logo_path\' => \'https://www.google.com/img/icons/src/logo.svg\',
\'currency\' => \'CAD\',
\'https://www.youtube.com/user/somewebsite/ogog\',
\'https://www.instagram.com/somewebsite/\',
),
);
>>>>>>> ff6df3435231fdff78fwsd83e7dffa0732eft554
// Somes code
$done[\'rules\'] = TRUE;';
my $regex = qr/^<<<<<<< HEAD(?:(?!=======)[\s\S])*=======(?:(?!>>>>>>> \w+)[\s\S])*>>>>>>> \w+/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