use strict;
my $str = '[[Kategória:Rakúski anarchisti]]
[[Kategória:Rakúski filozofi]]
[[Kategória:Osobnosti z Viedne]]
[[Kategória:Rakúski automobiloví pretekári|F1]]
[[Kategória:Rakúski športovci|Automobiloví pretekári]]
[[Kategória:Automobiloví pretekári podľa štátu|Rakúsko]]
[[Kategória: ]]
<comment>-[[Kategória:Literárne žánre]]; -[[Kategória:Filmové žánre]] pomocou použitia HotCat</comment>
<comment>+[[Kategória:Zaniknuté monarchie]]; +[[Kategória:Zaniknuté štáty Európy]]; +[[Kategória:Zaniknuté štáty Ázie]] pomocou použitia HotCat[[Kategória: ]]</comment>
<comment>odobratá [[Kategória:Dvojtisícovky]]; pridaná [[Kategória:Dvojtisícovky na Slovensku]] pomocou použitia HotCat</comment>
<comment>-[[Kategória:Technika]]; ±[[Kategória:Biológia]]→[[Kategória:Akvaristika]] pomocou použitia HotCat</comment>
<comment><!-- [[Kategória:Civilizácia]] -->, [[Kategória:Civilizácie]]</comment>
[[Kategória:User fa|{{PAGENAME}}]][[Kategória:User fa-N|{{PAGENAME}}]] &#1586;&#1576;&#1575;&#1606; &#1605;&#1575;&#1583;&#1585;&#1740; &#1575;&#1740;&#1606; &#1705;&#1575;&#1585;&#1576;&#1585; &#1575;&#1587;&#1578;</span><hr/><span style="font-size: 8pt;">This user is a native speaker of \'\'\'[[:Kategória:User fa|Persian]]\'\'\'.</span>
odobratá [[Kategória:Osobnosti z Málagy]]; pridaná [[Kategória:Osobnosti z Malagy]]
Toto nechceme:
Taktiež môžete zaradiť článok do tzv. kategórie s ostatnými súvisiacimi článkami. Stačí ak napíšete <nowiki>[[Kategória:]]</nowiki> a názov kategórie medzi dvojbodku a hranaté zátvorky. Viac informácií nájdete na stránke o [[Wikipédia:Kategórie|kategóriách]].
1. I have a two pets - dog and a cat
2. I have a pet - dog';
my $regex = qr/\[\[Kategória:[^\]\]]+\]\]/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