use strict;
my $str = '----Document Start-------
Paragraph*
RIASWIX.* ABCDEF1 NONE
WORKING: HELLO(READ)
BOOLEAN Access: SADGRE3, VJFKES3, JGJKEWW, IS4DWF44(A), DFEAWE2(G),
DW4444W, IHFK3MF3
BAZAAR Access: No resource with BAZAAR Access
GHAR Access: No resource with GHAR Access
WATER Access: ADMINDDD(A), GEDDE33
SKY None: No Resource with Sky Access
RIASWIX.@7483NFJ.* HFDFDF3 NONE
WORKING: BYE(READ)
BOOLEAN Access: GRREGGG, GREFEFF, GFGGGG, FDFDFDF(A), RERERE3(G),
GFFWEF44, FFRF44F
BAZAAR Access: No resource with BAZAAR Access
GHAR Access: No resource with GHAR Access
WATER Access: ADMINEWW(A), FFRFRGR
SKY None: No Resource with Sky Access
RIASWIX.@7483KXX.* HFDFDF3 NONE
WORKING: TATA(READ)
BOOLEAN Access: GRDSD33, FASDE, GFGGGG, RWERW33(A), NMUYHT4(G),
BAZAAR Access: XCDFEFE3, FREFE33R
GHAR Access: No resource with GHAR Access
WATER Access: DASDEFG(A), SJMFEIOE(P)
SKY None: No Resource with Sky Access
*Text
----Document End-------';
my $regex = qr/RIASWIX.*?Sky Access/msp;
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