use strict;
my $str = '# Oh yeah, good luck with that.
?? Can I use the gun?
Enough about your promiscuous mother, Hermes! We have bigger problems.
!!- Guards! Bring me the forms I need to fill out to have her taken away!
TODO Shinier than yours, meatbag.
- Wow, you got that off the Internet?
- In my day, the Internet was only used to download pornography.
Would you censor the Venus de Venus just because you can see her spewers?
! No argument here.
RWC: Oh no! The professor will hit me!
[] But if Zoidberg \'fixes\' it… then perhaps gifts!
I was all of history\'s great robot actors - Acting Unit 0. 8; Thespomat; David Duchovny!
[] Five hours? Aw, man! Couldn\'t you just get me the death penalty?
When I was first asked to make a film about my nephew, Hubert Farnsworth, I thought "Why should I?" Then later, Leela made the film. But if I did make it, you can bet there would have been more topless women on motorcycles. Roll film! Um, is this the boring, peaceful kind of taking to the streets?
';
my $regex = qr/(\B(\?\?|\?)|\B(\!\!|\!)|\B(\[\])|\b(RWC)|\b(TODO))[:;.,-]?\d*($|\s.*$|\(.*$)/mip;
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