use strict;
my $str = ' Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2017-02-01T11:29:03.000000Z
playback_requirements: QuickTime 6.0 or greater
playback_requirements-eng: QuickTime 6.0 or greater
encoder : vlc 2.2.4 stream output
encoder-eng : vlc 2.2.4 stream output
Duration: 00:00:12.52, start: 0.000000, bitrate: 3597 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 3475 kb/s, 21.57 fps, 23.98 tbr, 1000k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2017-02-01T11:29:03.000000Z
handler_name : VideoHandler
Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2017-02-01T11:29:03.000000Z
handler_name : SoundHandler';
my $regex = qr/Duration:\s{1}(\d+?):(\d+?):(\d+\.\d+?),/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