const regex = /[A-Z]{1,}.*?\d+-\d+-\d+-\d+[\s\S]*?\s{3,}\d+-\d+-\d+-[A-Za-z0-9]{4}/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('[A-Z]{1,}.*?\\d+-\\d+-\\d+-\\d+[\\s\\S]*?\\s{3,}\\d+-\\d+-\\d+-[A-Za-z0-9]{4}', 'gm')
const str = ` DATE: 02 July 2019
--------------------------------------------------------------------------------------------
WELL NAME LICENCE NUMBER MINERAL RIGHTS GROUND ELEVATION
UNIQUE IDENTIFIER SURFACE CO-ORDINATES BOARD FIELD CENTRE PROJECTED DEPTH
LAHEE CLASSIFICATION FIELD TERMINATING ZONE
DRILLING OPERATION WELL PURPOSE WELL TYPE SUBSTANCE
LICENSEE SURFACE LOCATION
--------------------------------------------------------------------------------------------
MEG K7N HARDY 4-7-77-5 0483923 ALBERTA CROWN 571.7M
106/04-07-077-05W4/02 S 572.4M W 278.3M BONNYVILLE 1600.0M
DEV (NC) HARDY MCMURRAY FM
HORIZONTAL RESUMPTIONPRODUCTION (SCHEME) CRUDE BITUMEN
MEG ENERGY CORP. 09-07-077-05W4
SPL 11-24 HZ MARTEN 14-25-76-6 0494994 ALBERTA CROWN 705.3M
100/14-25-076-06W5/00 S 566.0M E 800.6M ST. ALBERT 2700.0M
OUT (C) MARTEN CLEARWATER FM
HORIZONTAL NEW PRODUCTION CRUDE OIL
SPUR PETROLEUM LTD. 11-24-076-06W5 `;
// 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