use strict;
my $str = 'WEBVTT
1
00:00:00.310 --> 00:00:02.540
Dans cette séquence, nous
allons voir pourquoi nos
2
00:00:02.550 --> 00:00:05.210
assistants personnels,
smartphones et tablettes, sont
3
00:00:05.210 --> 00:00:07.420
devenus tout
naturellement, en une dizaine d\'années
4
00:00:07.420 --> 00:00:10.100
seulement, un point de collecte
majeur de données personnelles.
5
00:00:10.520 --> 00:00:13.140
Pourquoi le smartphone
intéresse-t-il tant de monde ?
6
00:00:15.690 --> 00:00:17.550
Tout d\'abord, il faut
être conscient que dans un
7
00:00:17.550 --> 00:00:20.110
smartphone, 2 niveaux
existent. Il y a la partie visible
8
00:00:20.150 --> 00:00:23.440
avec son processeur dont on
va vanter les performances,
9
00:00:23.440 --> 00:00:26.260
le système d\'exploitation
- dans ce module, nous nous';
my $regex = qr/^(\d{2}:\d{2}:\d{2}[.,]\d{3})\s-->\s(\d{2}:\d{2}:\d{2}[.,]\d{3})\n(.*(?:\r?\n(?!\r?\n).*)*)/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