use strict;
my $str = '0:\'ingen\',1:\'menneske\',2:\'mennesker\'
0:=\'ingen\',-1:\'fugl\'
1:\'cola\',2-:\'colar\'
0:=\'ingen\',0:\'biler\',1:\'bil\',2:\'biler\',3-:\'bøller\'
{{0:\'ingen\',1:\'menneske\',2:\'mennesker\'}}
{{0-2:=\'ingen\',0-1:\'fugl\'}}
{{1:\'cola\',2-:\'colar\'}}
{{0:=\'ingen\',0:\'biler\',1:\'bil\',2:\'biler\',3-:\'bøller\'}}
Single ${{var}}
Vi er ${{var_U}}{{0:\'ingen\',1:\'menneske\',2:\'mennesker\'}}
Der er en ${{var_1}}{{0:=\'ingen\',0-1:\'fugl\'}}
Gi\' mig ${{var}}{{1:\'cola\',2-:\'colar\'}}
Jeg har ${{var}}{{0:=\'ingen\',0:\'biler\',1:\'bil\',2:\'biler\',3-:\'bøller\'}}
\\$\\{\\{(.+)\\}\\}\\{\\{((\\d)(\\-)?(\\d)?(:(=)?)\\\'(.+)\\\'),?\\}\\}
\\${{([A-Za-z\\_\\d]+)}}((?:{{)?((\\d-?\\d?)(:=?)\\\'(.*?)\\\'),?(?:}})?)?
\\${{(?P<var>[A-Za-z09_]+)}}({{(?:(?P<factorL>\\d)?(?P<diff>\\-)?(?P<factorH>\\d)?(?P<assert>:=?)(\\\'(?P<string>.+?)\\\')+?)?}})?
{{([A-Za-z0-9_]+)}}(?:{{((\\d?\\-?\\d?)(:=?)(\'.+?\'),?)+}})?';
my $regex = qr/(?:{{(?:(\d?\-?\d?)(:=?)('[^']*'),*).*?}})/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