use strict;
my $str = '90.12.21 / 02.05 / XO3 File Name Type
10.22.43 / X.89 / XO20G9992 Document Internal Only
Phase 3
22.32.42.12 / 99.23 / XO2 Location Site 3: Park Triangle
38.23.99.22 / X.23 / XO28W9998 Block 4 Beach/Dock Camp
39.24.32.49 / 37.29 / Blue-print/Register Info Site (RISs)
23.21.53.32 / Q.21 / XO R9924 Location Place 5: Drive Place (Active)
33.51.63.33 / X.21 / XO20W8812 Area Place 1: Beach Drive';
my $regex = qr/.*\s(?:/\s+XO[A-Z0-9\s]*\b|/)\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