const regex = /failing[\w\W]*?\d*\)\s[\w\W]*?\:[\s\S]*?(Assert[\w\W]*?)[\n].*(src[^:]+):(\d+):(\d+)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('failing[\\w\\W]*?\\d*\\)\\s[\\w\\W]*?\\:[\\s\\S]*?(Assert[\\w\\W]*?)[\\n].*(src[^:]+):(\\d+):(\\d+)', 'g')
const str = ` 1) validates input
0 passing (660ms)
1 failing
1) statement:propose validates input:
AssertionError: expected { Object (status, err) } to have a deep property 'err' of 'err1', but got 'Error while fetching the changes from the event store: {}'
at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:307:16)
at .<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:21)
at ctx.(anonymous function) [as property]
at src/aggregate/index.js:144:100
(node_modules/chai/lib/chai/utils/overwriteMethod.js:49:33)
at Context.<anonymous> (src/aggregate/test/index.js:44:36)
`;
// 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