const regex = /^\d{2}\/(.++\n){3}(?=.+Success)(.++\n){3}(?=.+ABC).++/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^\\d{2}\\\/(.++\\n){3}(?=.+Success)(.++\\n){3}(?=.+ABC).++', 'gm')
const str = `04/09/2018 06:31:59 AM [class | Info] some message received from 101592 (123.123.123.124)
Request Id: 0 (Descriptor: 0, Operator Request Id: 0)
A type: bar
A status: Queued
The id: 1E25
Additional info: Inserted in queue at position 1 on device ABC
Location: ABC, subarea: 2
04/09/2018 06:31:59 AM [class | Info] some message received from 102364 (123.123.123.123)
Request Id: 0 (Descriptor: 0, Operator Request Id: 0)
A type: bar
A status: Queued
The id: 1E25
Additional info: Inserted in queue at position 1 on device ABC
Location: ABC, subarea: 2
04/09/2018 06:31:59 AM [class | Info] some message received from 102364 (123.123.123.123)
Request Id: 0 (Descriptor: 0, Operator Request Id: 0)
A type: blah bit foo
A status: Success
The id: T908
Additional info:
Location: DEF, subarea: 3
04/09/2018 06:32:00 AM [class | Info] some message received from 102364 (123.123.123.123)
Request Id: 0 (Descriptor: 0, Operator Request Id: 0)
A type: bar
A status: Success
The id: DG08
Additional info:
Location: ABC, subarea: 1`;
// 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