use strict;
my $str = 'ITGIS.COMP_OP_STN cos
ITGIS.NS_DIVISIONS nsd
ITGIS.COMP_OP_STN cos
ITGIS.NSPD_RESP_ZONE nrz
ITGIS.COMP_OP_STN cos
PUBDATA.US_COUNTIES usc
ITGIS.COMP_OP_STN cos
PUBDATA.US_CITIES_BOUNDARIES uscb
ITGIS.COMP_OP_STN cos
nsdMatches nsd
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
NFSAPP.CONTROL nfsac
PUBDATA.US_CITIES c
ENGXING.CI_LOCATIONANDCLASSIFICATION cils
ITGIS.NS_DIVISIONS nsd
ENGXING.CI_LOCATIONANDCLASSIFICATION cils
ITGIS.NSPD_RESP_ZONE nrz
ENGXING.CI_LOCATIONANDCLASSIFICATION cils
PUBDATA.US_COUNTIES usc
ENGXING.CI_LOCATIONANDCLASSIFICATION cils
PUBDATA.US_CITIES_BOUNDARIES uscb
ENGXING.DOTLIST dl
INNER JOIN ENGXING.CI_LOCATIONANDCLASSIFICATION cils
ENGXING.INVENTORY_QUE q
nsdMatches nsd
ENGXING.CI_OPERATINGRAILROAD cior
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
ENG.ENG_CROSSING ec
NFSAPP.CONTROL nfsac
PUBDATA.US_CITIES c
EGIS.ENG_MPMARK mp
ITGIS.NS_DIVISIONS nsd
EGIS.ENG_MPMARK mp
ITGIS.NSPD_RESP_ZONE nrz
EGIS.ENG_MPMARK mp
PUBDATA.US_COUNTIES usc
EGIS.ENG_MPMARK mp
PUBDATA.US_CITIES_BOUNDARIES uscb
EGIS.ENG_MPMARK mp
nrzMatches nrz
nsdMatches nsd
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
NFSAPP.CONTROL nfsac
PUBDATA.US_CITIES c
EGIS.ENG_SWITCH s
ITGIS.NS_DIVISIONS nsd
EGIS.ENG_SWITCH s
ITGIS.NSPD_RESP_ZONE nrz
EGIS.ENG_SWITCH s
PUBDATA.US_COUNTIES usc
EGIS.ENG_SWITCH s
PUBDATA.US_CITIES_BOUNDARIES uscb
EGIS.ENG_SWITCH s
nsdMatches nsd
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
NFSAPP.CONTROL nfsac
PUBDATA.US_CITIES c
EGIS.ENG_TOWER t
ITGIS.NS_DIVISIONS nsd
EGIS.ENG_TOWER t
ITGIS.NSPD_RESP_ZONE nrz
EGIS.ENG_TOWER t
PUBDATA.US_COUNTIES usc
EGIS.ENG_TOWER t
PUBDATA.US_CITIES_BOUNDARIES uscb
EGIS.ENG_TOWER t
nsdMatches nsd
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
PUBDATA.US_CITIES c
ITGIS.COMP_AEI_SCNR s
ITGIS.NS_DIVISIONS nsd
ITGIS.COMP_AEI_SCNR s
ITGIS.NSPD_RESP_ZONE nrz
ITGIS.COMP_AEI_SCNR s
PUBDATA.US_COUNTIES usc
ITGIS.COMP_AEI_SCNR s
PUBDATA.US_CITIES_BOUNDARIES uscb
ITGIS.COMP_AEI_SCNR s
nsdMatches nsd
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
NFSAPP.CONTROL nfsac
PUBDATA.US_CITIES c
ITGIS.NSPD_LOCATIONS l
ITGIS.NS_DIVISIONS nsd
ITGIS.NSPD_LOCATIONS l
ITGIS.NSPD_RESP_ZONE nrz
ITGIS.NSPD_LOCATIONS l
PUBDATA.US_COUNTIES usc
ITGIS.NSPD_LOCATIONS l
PUBDATA.US_CITIES_BOUNDARIES uscb
ITGIS.NSPD_LOCATIONS l
nsdMatches nsd
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
PUBDATA.US_CITIES c
NSPD.NSPD_POI poi
ITGIS.NS_DIVISIONS nsd
NSPD.NSPD_POI poi
ITGIS.NSPD_RESP_ZONE nrz
NSPD.NSPD_POI poi
PUBDATA.US_COUNTIES usc
NSPD.NSPD_POI poi
PUBDATA.US_CITIES_BOUNDARIES uscb
NSPD.NSPD_POI poi
nsdMatches nsd
nrzMatches nrz
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
PUBDATA.US_CITIES c
ITGIS.ITGIS_MP100S mp
ITGIS.NS_DIVISIONS nsd
ITGIS.ITGIS_MP100S mp
ITGIS.NSPD_RESP_ZONE nrz
ITGIS.ITGIS_MP100S mp
PUBDATA.US_COUNTIES usc
ITGIS.ITGIS_MP100S mp
PUBDATA.US_CITIES_BOUNDARIES uscb
ITGIS.ITGIS_MP100S mp
NFSAPP.CONTROL nfsac
nrzMatches nrz
nsdMatches nsd
cityBoundaryMatches
countyMatches
ITGIS.NSPD_LOCATIONS nl
ITGIS.NS_DIVISIONS nd
PUBDATA.US_CITIES c
';
my $regex = qr/\s{1,}\S{1,}$/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