use strict;
my $str = '363
00:22:09,395 --> 00:22:11,996
Because he did only
meet me the once.
364
00:22:11,998 --> 00:22:13,597
Perhaps I could...
365
00:22:20,105 --> 00:22:21,772
(CLAMOURING)
366
00:22:21,774 --> 00:22:25,009
(INDISTINCT ANNOUNCEMENT
OVER PA)
367
00:22:55,340 --> 00:22:58,509
(INDISTINCT ANNOUNCEMENT
OVER PA)
368
00:23:10,655 --> 00:23:11,389
SARAH: Excuse me.
369
00:23:11,391 --> 00:23:14,225
Were there any men flying
alone on this fligh';
my $regex = qr/(\-?\(.*\))/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