use strict;
my $str = 'id : 42cdb643-0a11-416b-b66b-7bb28a9a20ea
isReadOnly : False
somestring : False
somestring : {}
name :
id : d006d69e-8d04-48d7-8806-cdc39c18e679
somestring : False
somestring : False
somestring : 822F0340-818A-4F23-AA78-633B6436913F
upstreamDataflowsOfDatasets : {}';
my $regex = qr/\bid\s+:\s*\b([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})\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