use strict;
my $str = '1
00:00:00,000 --> 00:00:00,500
moi j\'ai
fait des
2
00:00:00,500 --> 00:00:01,780
rêves lucides
3
00:00:01,780 --> 00:00:03,340
mais j’ai
jamais essayé
4
00:00:03,340 --> 00:00:03,820
d\'en faire
5
00:00:03,820 --> 00:00:04,700
ou quoi
6
00:00:04,700 --> 00:00:05,500
J\'ai dû
en faire
7
00:00:05,500 --> 00:00:06,720
genre cinq
8
00:00:06,720 --> 00:00:07,380
mais il y en
9
00:00:07,380 --> 00:00:09,160
a deux des cinq
où vraiment
10
00:00:09,160 --> 00:00:10,260
je faisais
ce que je veux
11
00:00:10,260 --> 00:00:11,080
Genre j\'ai volé
12
00:00:11,080 --> 00:00:12,100
tout ce à quoi
je pensais
13
00:00:12,100 --> 00:00:12,720
je le faisais
14
00:00:12,720 --> 00:00:13,260
c\'était
vraiment
15
00:00:13,260 --> 00:00:14,040
tranquille
bon c\'était
16
00:00:14,040 --> 00:00:14,640
pendant
ma période
17
00:00:14,640 --> 00:00:16,140
où j\'étais
un peu
18
00:00:16,140 --> 00:00:16,800
dans un autre
monde
19
00:00:16,800 --> 00:00:17,360
de manière
générale
20
00:00:17,360 --> 00:00:17,720
Et j\'ai fait
21
00:00:17,720 --> 00:00:18,820
l\'inverse aussi
22
00:00:18,820 --> 00:00:20,460
où j\'étais
réveillé Ça
23
00:00:20,460 --> 00:00:20,800
j\'ai jamais
24
00:00:20,800 --> 00:00:21,280
fait Par contre
25
00:00:21,280 --> 00:00:21,900
et heureusement
26
00:00:21,900 --> 00:00:22,580
parce que
ça a l\'air
27
00:00:22,580 --> 00:00:23,680
tellement
flippant
28
00:00:23,680 --> 00:00:24,740
J\'adorais
vivre ça
29
00:00:24,740 --> 00:00:26,100
ah t’es unn
malade
30
00:00:26,100 --> 00:00:26,740
Mais attendez
31
00:00:26,740 --> 00:00:27,960
une expérience
négative
32
00:00:27,960 --> 00:00:28,920
est une bonne
expérience
33
00:00:28,920 --> 00:00:30,620
Moi j\'ai
une amoureuse
34
00:00:30,620 --> 00:00:31,520
qui vit ça
35
00:00:31,520 --> 00:00:32,140
très souvent
36
00:00:32,140 --> 00:00:32,460
j’ai pas envie
37
00:00:32,460 --> 00:00:32,880
d\'en faire 20
38
00:00:32,880 --> 00:00:33,740
mais et je peux
te dire
39
00:00:33,740 --> 00:00:35,020
qu\'elle n\'en
peut plus quoi';
my $regex = qr/\> .+\s+(?<text>[\w\W]+?)(?=\s+\d+\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