const regex = /VSID_W_MAX_TRAN_DT.+?=(?=\s) (?<VSID_W_MAX_TRAN_DT>[^\s]+)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('VSID_W_MAX_TRAN_DT.+?=(?=\\s) (?<VSID_W_MAX_TRAN_DT>[^\\s]+)', 'gm')
const str = `VMID_COUNT =========== 20,588,655
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
Table.+.+?(?=\\.)\\W*(opcode_tedc_cs_gmr_id_delta)\\W.+?(?=,+)\\,\\s+numRows\\=+(?<LogTime>[^\\,]+)
Loading data to table gmr.opcode_tedc_cs_gmr_id_delta
Table gmr.opcode_tedc_cs_gmr_id_delta stats: [numFiles=5, numRows=8986691, totalSize=937732401, rawDataSize=928745710]
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 997 100 997 0 0 114k 0 --:--:-- --:--:-- --:--:-- 162k
0 0 0 397 0 0 1650 0 --:--:-- --:--:-- --:--:-- 1650
VSID_W_MAX_TRAN_DT ========== 9,070,691
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 997 100 997 0 0 108k 0 --:--:-- --:--:-- --:--:-- 139k
0 0 0 403 0 0 944 0 --:--:-- --:--:-- --:--:-- 944
NON_PSP_VSID_COUNT =========== 39,869,169
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 997 100 997 0 0 112k 0 --:--:-- --:--:-- --:--:-- 162k
0 0 0 398 0 0 7223 0 --:--:-- --:--:-- --:--:-- 7223
PSP_VSID_COUNT =========== 45,083
sendmail: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
postdrop: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
[send_coll_stats.sh:] Sent e-mail with collection stats
/jobs/prod/proclib/CMLS_HADOOP_proc_v02.ksh: line 75: print: command not found
/jobs/prod/proclib/CMLS_trailer.ksh: line 9: print: command not found`;
// 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