use strict;
my $str = '2018-04-16T08:09:27.203Z cae70dd2-414c-11e8-836a-354cb4985a41 https 2018-04-15T01:20:31.092381Z app/MBM-L-Publi-V9D386A91UNR/4695f2e72859f540 128.121.50.133:59367 10.0.1.14:80 0.001 0.003 0.000 200 200 934 282 "GET https://www.domain.tld:443/__utm.gif?v=1&_v=j66&a=1866784098&t=pageview&_s=1&dl=https%3A%2F%2Fwww.domain.tld%2Fnews%2Farchived%2Fresources-archived%22001-11%2F&ul=en-us&de=UTF-8&dt=Racal%20reborn%20after%20Thales%20buyout&sd=24-bit&sr=412x732&vp=404x732&je=0&cid=1296878891.1495497600&_gid=1908154735.1495497600&_r=1&z=821631926 HTTP/1.1" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 arn:aws:elasticloadbalancing:eu-west-2:123456789012:targetgroup/MBM-L-Cache-1LH0DNU489D55/167e4810f75804c3 "Root=1-5ad2a8df-021aaad5031047e7dec3f2fa" "www.domain.tld" "arn:aws:acm:eu-west-2:123456789012:certificate/1140cbb2-4d4f-44b0-a4d9-a79329c5e361" 0';
my $regex = qr/"[^"]*"|\S+/p;
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