const regex = /\s{1,}\S{1,}$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\s{1,}\\S{1,}$', 'gm')
const 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
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions