use strict;
my $str = '{{Song box 2
|color = black; color:#D7DA5F
|image = Kokoropv.jpg
|title = "\'\'\'ココロ\'\'\'"
* Romaji: Kokoro
* Official English: Heart
|date = March 2, 2008
|views = {{v|nn|2,738,496}}
|singers = [[Kagamine Rin]] act1
|producers = [[Toraboruta-P]] (music, lyrics, illustration)
|links = {{l|nn|sm2500648}} {{l|mz|266689|defunct}}
|links = {{l|nn|sm2500648}} {{l|mz|266689|defunct}}
}}';
my $regex = qr/\|links *= *(\s*?.*?)*?^/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