const regex = new RegExp('[0-9]{1,2}+:[0-9]{1,2}+:[0-9]{1,2}+\\.[0-9]{1,3}+.*REST REQUEST(?:\\n[^\\S\\n]*\\S.*)+', 'gm')
const str = `12:56:13.861 [http-nio-7777-exec-1] INFO dg.mpro.filter.CustomRequestLoggingFilter - REST REQUEST
NUMBERS OF REQUESTS:= [1]
METHOD:= [GET]
PARAMETERS & VALUES :=
REQUEST:= [/rest/indexv2/getMetadata]
12:56:13.861 [http-nio-7777-exec-1] INFO dg.mpro.filter.CustomRequestLoggingFilter - Response time: 1 seconds
13:14:46.049 [http-nio-7777-exec-2] INFO dg.mpro.filter.CustomRequestLoggingFilter - REST REQUEST
NUMBERS OF REQUESTS:= [2]
METHOD:= [GET]
PARAMETERS & VALUES := [pagesize:= 20][name:= Mosolv][page:= 1][tolerance:= 4]
REQUEST:= [/rest/indexv2/getProds/{{licensekey}}/{{username}}/%7B%22tolerance%22:%224%22,%22pagesize%22:%2220%22,%22name%22:%22Mosolv%22,%22page%22:%221%22%7D]
13:14:46.050 [http-nio-7777-exec-2] INFO dg.mpro.filter.CustomRequestLoggingFilter - Response time: 2 seconds
12:57:14.812 [http-nio-7777-exec-1] INFO dg.mpro.filter.CustomRequestLoggingFilter - REST REQUEST
NUMBERS OF REQUESTS:= [3]
METHOD:= [GET]
PARAMETERS & VALUES :=
REQUEST:= [/rest/indexv2/getMetadata]
12:57:14.813 [http-nio-7777-exec-1] INFO dg.mpro.filter.CustomRequestLoggingFilter - Response time: 1 seconds`;
// 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