use strict;
my $str = '[1 min: STR-Armor Rating](swept downstream to [room L]/able to reach edge)
[1min: STR DC 12](swept downstream to [room L]/able to reach edge)
[12 hr: STR DC 12](swept downstream to [room L]/able to reach edge)
How does one [WIS@15](fail info/pass info 1)
[ssdsd](sd/ds)
[ssdsd](-/ds)
[ssdsd](player is Incapacitated for 1d4 rounds/-)
[Con](sleep for 1d6x10 minutes/-)
[Dex](2d6 damage/half)
[CON](lose 1hp every minute/-)
[STR](-/upward thrust dislodges debris - critical: door opens)
[DEX](slide down to pit/-)
[level 2 - room T]
[CON-Armor Rating](1d8 damage/-)
[STR-Armor Rating](swept downstream to [room L]/able to reach edge)
[Dex](-/pull up bracelet with chain)
[paralyze](paralyzed 3d6 turns/-)
[wis](cannot understand/-)
[poison](unconscious 1d6 turns/-)';
my $regex = qr/((?<stat>\w+)(\s*([Dd][cC]|@)\s*(?<num>\d+))?|())\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