use strict;
my $str = '\'\\u001b[1m\\u001b[31m \\u001b[1m● \\u001b[1mregister page › register-automated › desktop › CONTROL\\u001b[39m\\u001b[22m\\n\\n Expected image to match or be a close match to snapshot but was 0.009980258828690502% different from snapshot (91 differing pixels).\\n \\u001b[1m\\u001b[31mSee diff for details:\\u001b[39m\\u001b[22m \\u001b[31m/src/pages/__image_snapshots__/__diff_output__/register-test-js-register-page-register-automated-desktop-control-1-diff.png\\u001b[39m\\n\\u001b[2m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 60 | \\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 61 | \\u001b[39m \\u001b[36mconst\\u001b[39m image \\u001b[33m=\\u001b[39m await page\\u001b[33m.\\u001b[39mscreenshot({ fullPage\\u001b[33m:\\u001b[39m isFullPage })\\u001b[33m;\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m\\u001b[31m\\u001b[1m>\\u001b[2m\\u001b[39m\\u001b[90m 62 | \\u001b[39m expect(image)\\u001b[33m.\\u001b[39mtoMatchImageSnapshot({threshold\\u001b[33m:\\u001b[39m \\u001b[35m0.3\\u001b[39m})\\u001b[33m;\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m | \\u001b[39m \\u001b[31m\\u001b[1m^\\u001b[2m\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 63 | \\u001b[39m })\\u001b[33m;\\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 64 | \\u001b[39m\\u001b[0m\\u001b[22m\\n\\u001b[2m \\u001b[0m \\u001b[90m 65 | \\u001b[39m \\u001b[36mif\\u001b[39m(experimentName \\u001b[33m||\\u001b[39m experiementVariationName) {\\u001b[0m\\u001b[22m\\n\\u001b[2m\\u001b[22m\\n\\u001b[2m \\u001b[2mat Object.toMatchImageSnapshot (\\u001b[2msrc/command/getPageImageShot.js\\u001b[2m:62:25)\\u001b[2m\\u001b[22m\\n\'
';
my $regex = qr/details:.*?(\/src\/.*?\.png\b)/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